Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
747827d
feat: Remove base64 encoder
HazAT Oct 30, 2018
77fb4d4
feat: Rename configuration to options
HazAT Oct 30, 2018
b58a2f8
feat: Remove unused API from the client
HazAT Oct 30, 2018
ba38150
feat: Move captureLastError to SDK
HazAT Oct 30, 2018
ce275cb
fix: Variable name
HazAT Oct 30, 2018
7a5fb6f
feat: Internal refactorings, Add prepareEvent
HazAT Oct 30, 2018
c140822
feat: First part of middleware / integration cleanup
HazAT Oct 30, 2018
3735622
feat: Major refactorings, Introduce Integration
HazAT Oct 31, 2018
0c85828
feat: Add setupIntegrations
HazAT Nov 5, 2018
caa1aaf
feat: Error handler
HazAT Nov 5, 2018
a55f4cd
feat: Add transport as option
HazAT Nov 5, 2018
ac00f7c
fix: ExceptionIntegration tests
HazAT Nov 5, 2018
43462fb
feat: Add tests for request integration
HazAT Nov 5, 2018
fd480a4
feat: Update tests
HazAT Nov 6, 2018
dc36f2b
fix: phpstan
HazAT Nov 6, 2018
947f9a6
ref: Remove ClientBuilder
HazAT Nov 6, 2018
8527d5b
Revert "ref: Remove ClientBuilder"
HazAT Nov 7, 2018
8f82cdd
fix: Tests and ClientBuilder
HazAT Nov 7, 2018
d014ae6
fix: Tests
HazAT Nov 7, 2018
7f260b9
fix: All Tests
HazAT Nov 7, 2018
98f8664
meta: Enable all tests
HazAT Nov 7, 2018
d7be195
ref: Rename integrations
HazAT Nov 7, 2018
cf537bc
ref: Code Review
HazAT Nov 8, 2018
7129ce4
fix: Add more tests
HazAT Nov 8, 2018
119e635
feat: Wrap breadcrumbs in values, Fix sdk identifier
HazAT Nov 8, 2018
323bffb
fix: Make module integration opt in
HazAT Nov 8, 2018
b0017b1
ref: Code review changes
HazAT Nov 13, 2018
1353e9d
ref: Minor changes
HazAT Nov 13, 2018
d4eef2d
ref: Code review changes
HazAT Nov 13, 2018
9f9bb24
feat: Remove transport as an option
HazAT Nov 13, 2018
1717101
feat: Remove exception integration
HazAT Nov 14, 2018
504b0fb
ref: Remove try catch
HazAT Nov 14, 2018
8a39f63
ref: Extract serializer from Stacktrace
HazAT Nov 14, 2018
ae738ef
feat: Add typecheck for integration options
HazAT Nov 14, 2018
4377cf6
ref: Code Review
HazAT Nov 14, 2018
ff31ea4
ref: Code review
HazAT Nov 15, 2018
ae50e3a
ref: Code Review
HazAT Nov 15, 2018
dc890e6
Fix and refactor ErrorHandler test
Jean85 Nov 15, 2018
a331274
Fix regex for PHPT test expectation
Jean85 Nov 15, 2018
126c807
Fix CS
Jean85 Nov 15, 2018
5b76c17
fix: use call_user_func
HazAT Nov 15, 2018
5278a0e
ref: Code Review
HazAT Nov 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: test
gc -am .PHONY: test

develop: update-submodules
composer install --dev
Expand Down
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ parameters:
- src
- tests
ignoreErrors:
- '/Constructor of class Sentry\\HttpClient\\Encoding\\Base64EncodingStream has an unused parameter \$(readFilterOptions|writeFilterOptions)/'
- '/Call to an undefined method Sentry\\ClientBuilder::methodThatDoesNotExists\(\)/'
- '/Argument of an invalid type object supplied for foreach, only iterables are supported/'
- '/Binary operation "\*" between array and 2 results in an error\./'
- '/Method Sentry\\ClientBuilder::\w+\(\) should return \$this\(Sentry\\ClientBuilderInterface\) but returns \$this\(Sentry\\ClientBuilder\)\./'
- '/Parameter #1 \$values of class Sentry\\TransactionStack constructor expects array<string>, array<int, stdClass\|string> given\./'
# to be removed with serializer refactoring
- '/Parameter #1 \$data of method Sentry\\Context\\\w*Context::replaceData\(\) expects array, array\|bool\|float\|int\|object\|string\|null given\./'
excludes_analyse:
- tests/resources
includes:
Expand Down
32 changes: 18 additions & 14 deletions src/AbstractErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
abstract class AbstractErrorHandler
{
/**
* @var ClientInterface The Raven client
* @var callable Callback that will be invoked when an error is caught
*/
protected $client;
protected $callback;

/**
* @var \ReflectionProperty A reflection cached instance that points to the
Expand Down Expand Up @@ -80,16 +80,18 @@ abstract class AbstractErrorHandler
/**
* Constructor.
*
* @param ClientInterface $client The Raven client
* @param int $reservedMemorySize The amount of memory to reserve for the fatal error handler
* @param callable $callback The callback that will be invoked in case an error is caught
* @param int $reservedMemorySize The amount of memory to reserve for the fatal error handler
*
* @throws \ReflectionException
*/
protected function __construct(ClientInterface $client, $reservedMemorySize = 10240)
protected function __construct(callable $callback, int $reservedMemorySize = 10240)
{
if (!\is_int($reservedMemorySize) || $reservedMemorySize <= 0) {
throw new \UnexpectedValueException('The value of the $reservedMemorySize argument must be an integer greater than 0.');
}

$this->client = $client;
$this->callback = $callback;
$this->exceptionReflection = new \ReflectionProperty(\Exception::class, 'trace');
$this->exceptionReflection->setAccessible(true);

Expand All @@ -104,7 +106,7 @@ protected function __construct(ClientInterface $client, $reservedMemorySize = 10
if (null === $this->previousErrorHandler) {
restore_error_handler();

// Specifying the error types catched by the error handler with the
// Specifying the error types caught by the error handler with the
// first call to the set_error_handler method would cause the PHP
// bug https://bugs.php.net/63206 if the handler is not the first
// one
Expand Down Expand Up @@ -152,6 +154,8 @@ public function captureAt($levels, $replace = false)
*
* @return bool If the function returns FALSE then the normal error handler continues
*
* @throws \Throwable
*
* @internal
*/
public function handleError($level, $message, $file, $line)
Expand All @@ -169,8 +173,8 @@ public function handleError($level, $message, $file, $line)

try {
$this->handleException($errorAsException);
} catch (\Exception $exception) {
// Do nothing as this error handler should be as trasparent as possible
} catch (\Throwable $exception) {
// Do nothing as this error handler should be as transparent as possible
}

if (null !== $this->previousErrorHandler) {
Expand Down Expand Up @@ -211,7 +215,7 @@ public function handleFatalError(array $error = null)
if (null !== $errorAsException) {
$this->handleException($errorAsException);
}
} catch (\ErrorException $errorAsException) {
} catch (\Throwable $errorAsException) {
// Ignore this re-throw
}
}
Expand All @@ -220,9 +224,9 @@ public function handleFatalError(array $error = null)
* Handles the given exception by capturing it through the Raven client and
* then forwarding it to another handler.
*
* @param \Exception|\Throwable $exception The exception to handle
* @param \Throwable $exception The exception to handle
*
* @throws \Exception|\Throwable
* @throws \Throwable
*
* @internal
*/
Expand Down Expand Up @@ -320,9 +324,9 @@ protected function cleanBacktraceFromErrorHandlerFrames($backtrace, $file, $line
* Handles the given exception. This method can be overridden to customize
* the logging of an exception.
*
* @param \Exception|\Throwable $exception The exception to handle
* @param \Throwable $exception The exception to handle
*
* @throws \Exception|\Throwable
* @throws \Throwable
*/
abstract protected function doHandleException($exception);
}
93 changes: 0 additions & 93 deletions src/BreadcrumbErrorHandler.php

This file was deleted.

35 changes: 35 additions & 0 deletions src/Breadcrumbs/Breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,41 @@ public static function create($level, $type, $category, $message = null, array $
return new static($level, $type, $category, $message, $metadata);
}

/**
* Maps the severity of the error to one of the levels supported by the
* breadcrumbs.
*
* @param \ErrorException $exception The exception
*
* @return string
*/
public static function levelFromErrorException(\ErrorException $exception): string
{
switch ($exception->getSeverity()) {
case E_DEPRECATED:
case E_USER_DEPRECATED:
case E_WARNING:
case E_USER_WARNING:
case E_RECOVERABLE_ERROR:
return self::LEVEL_WARNING;
case E_ERROR:
case E_PARSE:
case E_CORE_ERROR:
case E_CORE_WARNING:
case E_COMPILE_ERROR:
case E_COMPILE_WARNING:
return self::LEVEL_CRITICAL;
case E_USER_ERROR:
return self::LEVEL_ERROR;
case E_NOTICE:
case E_USER_NOTICE:
case E_STRICT:
return self::LEVEL_INFO;
default:
return self::LEVEL_ERROR;
}
}

/**
* Gets the breadcrumb type.
*
Expand Down
Loading