Skip to content

Commit

Permalink
Don't share exception objects between threads
Browse files Browse the repository at this point in the history
  • Loading branch information
Muqsit committed Mar 4, 2024
1 parent 8ddd46e commit 4bf7607
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Tebex
main: muqsit\tebex\Loader
version: 0.1.9
version: 0.1.10
author: Muqsit
api: 5.0.0
permissions:
Expand Down
4 changes: 4 additions & 0 deletions src/muqsit/tebex/handler/PmmpTebexLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Logger;
use muqsit\tebexapi\utils\logger\TebexLogger;
use muqsit\tebexapi\utils\TebexException;
use Throwable;

final class PmmpTebexLogger implements TebexLogger{
Expand All @@ -16,5 +17,8 @@ public function __construct(

public function exception(Throwable $t) : void{
$this->logger->logException($t);
if($t instanceof TebexException && $t->extra_trace !== null){
echo $t->extra_trace;
}
}
}
4 changes: 2 additions & 2 deletions src/muqsit/tebex/thread/TebexThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ protected function onRun() : void{
try{
$response_holder = $connection_handler->handle($request_holder, $default_curl_opts);
}catch(TebexException $e){
$response_holder = new TebexResponseFailureHolder($request_holder->handler_id, $e);
$response_holder = new TebexResponseFailureHolder($request_holder->handler_id, $e->getLatency(), $e->getMessage(), $e->getCode(), $e->getTraceAsString());
}catch(Exception $e){
$response_holder = new TebexResponseFailureHolder($request_holder->handler_id, new TebexException($e->getMessage(), 5000, $e->getCode(), $e));
$response_holder = new TebexResponseFailureHolder($request_holder->handler_id, 5000, $e->getMessage(), $e->getCode(), $e->getTraceAsString());
}

$this->outgoing[] = igbinary_serialize($response_holder);
Expand Down

0 comments on commit 4bf7607

Please sign in to comment.