Skip to content

Commit

Permalink
Merge pull request #60 from pavelzotikov/fix-cyclinc-handling-and-res…
Browse files Browse the repository at this point in the history
…olve-bug-63206

Fix cyclic handling and resolve bug #63206 in error and exception han…
  • Loading branch information
pavelzotikov authored Sep 17, 2024
2 parents 5eadd0b + 1cb604b commit 654dc0a
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 99 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "PHP errors Catcher module for Hawk.so",
"keywords": ["hawk", "php", "error", "catcher"],
"type": "library",
"version": "2.2.1",
"version": "2.2.2",
"license": "MIT",
"require": {
"ext-curl": "*",
Expand Down
19 changes: 12 additions & 7 deletions src/Catcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class Catcher
private static $instance;

/**
* SDK handler: contains methods that catchs errors and exceptions
* SDK handler: contains methods that catch errors and exceptions
*
* @var Handler
*/
Expand Down Expand Up @@ -70,7 +70,7 @@ public static function get(): Catcher
*/
public function setUser(array $user): self
{
$this->handler->withUser($user);
$this->handler->setUser($user);

return $this;
}
Expand All @@ -82,7 +82,7 @@ public function setUser(array $user): self
*/
public function setContext(array $context): self
{
$this->handler->withContext($context);
$this->handler->setContext($context);

return $this;
}
Expand All @@ -99,7 +99,7 @@ public function setContext(array $context): self
*/
public function sendMessage(string $message, array $context = []): void
{
$this->handler->catchEvent([
$this->handler->sendEvent([
'title' => $message,
'context' => $context
]);
Expand All @@ -109,6 +109,8 @@ public function sendMessage(string $message, array $context = []): void
* @param Throwable $throwable
* @param array $context
*
* @throws Throwable
*
* @example
* \Hawk\Catcher::get()
* ->sendException($exception, [
Expand All @@ -117,7 +119,7 @@ public function sendMessage(string $message, array $context = []): void
*/
public function sendException(Throwable $throwable, array $context = [])
{
$this->handler->catchException($throwable, $context);
$this->handler->handleException($throwable, $context);
}

/**
Expand All @@ -131,7 +133,7 @@ public function sendException(Throwable $throwable, array $context = [])
*/
public function sendEvent(array $payload): void
{
$this->handler->catchEvent($payload);
$this->handler->sendEvent($payload);
}

/**
Expand All @@ -156,6 +158,9 @@ private function __construct(array $options)
$transport = new CurlTransport($options->getUrl());

$this->handler = new Handler($options, $transport, $builder);
$this->handler->enableHandlers();

$this->handler->registerErrorHandler();
$this->handler->registerExceptionHandler();
$this->handler->registerFatalHandler();
}
}
7 changes: 7 additions & 0 deletions src/Exception/SilencedErrorException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Hawk\Exception;

class SilencedErrorException extends \ErrorException
{
}
Loading

0 comments on commit 654dc0a

Please sign in to comment.