Skip to content

Commit

Permalink
refactor: refactored abstract Coder
Browse files Browse the repository at this point in the history
  • Loading branch information
petrknap committed Nov 2, 2024
1 parent 9b13b5f commit d1d92ce
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Coder/Coder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ public function encode(string $decoded): string
{
try {
return $this->doEncode($decoded);
} catch (Exception\CoderCouldNotEncodeData $exception) {
throw $exception;
} catch (Throwable $reason) {
if ($reason instanceof Exception\CoderCouldNotEncodeData) {
throw $reason;
}
throw new Exception\CoderCouldNotEncodeData(__METHOD__, $decoded, $reason);
}
}
Expand All @@ -24,10 +23,9 @@ public function decode(string $encoded): string
{
try {
return $this->doDecode($encoded);
} catch (Exception\CoderCouldNotDecodeData $exception) {
throw $exception;
} catch (Throwable $reason) {
if ($reason instanceof Exception\CoderCouldNotDecodeData) {
throw $reason;
}
throw new Exception\CoderCouldNotDecodeData(__METHOD__, $encoded, $reason);
}
}
Expand Down

0 comments on commit d1d92ce

Please sign in to comment.