Compare commits

..

No commits in common. "master" and "0.0.2" have entirely different histories.

15 changed files with 7442 additions and 305 deletions

1
.gitignore vendored
View file

@ -1,3 +1,2 @@
workspace.code-workspace workspace.code-workspace
vendor vendor
.vscode

22
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,22 @@
{
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
// Pointez pour afficher la description des attributs existants.
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}

View file

@ -2,40 +2,6 @@
All notable changes to `ExceptionHandler` will be documented in this file. All notable changes to `ExceptionHandler` will be documented in this file.
# version 2.0.0
- Changed enhance getAnonymizedMessage (for DB queries)
- Changed Support only for laravel 10
- Added env element EXCEPTION_MAIL_LIST
# version 0.1.1
- Changed better parsing for email recipients
- Changed if no recipients are available, a warning will be emitted, also native Laravel report method will be called instead.
- Changed if mail report fails, native reporting method will be called.
# version 0.1.0
- Add a a method to manually send exception by email (plus the same to call statically).
# version 0.0.9
- Multiline exception message in mail.
# version 0.0.8
- Make sure sending mail error is always correctly handled (write in logs)
# version 0.0.7
- Added support for laravel 9
# version 0.0.6
- Added class name to email message
# version 0.0.5
- Fixed Handle cases where exception came from a function instead of a class
# version 0.0.4
- Fixed Try to fix undefined index file error
## version 0.0.3
- Fixed getAnonymizedStackTrace change param type to Throwable
- Fixed remove finally on reportExceptionByEmail to let exceptions bubble
## version 0.0.2 ## version 0.0.2
Fix usage with laravel 7 Fix usage with laravel 7

View file

@ -17,11 +17,13 @@
"Policies" "Policies"
], ],
"require": { "require": {
"illuminate/support": "~10", "illuminate/support": "~7|~8",
"laravel/framework": "~10" "laravel/framework": "~7|~8"
}, },
"require-dev": { "require-dev": {
"slevomat/coding-standard": "^8.10" "phpunit/phpunit": "~9.0",
"squizlabs/php_codesniffer": "^3.5",
"orchestra/testbench": "^6.13"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -39,10 +41,5 @@
"Kwaadpepper\\ExceptionHandler\\ExceptionHandlerServiceProvider" "Kwaadpepper\\ExceptionHandler\\ExceptionHandlerServiceProvider"
] ]
} }
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
} }
} }

7242
composer.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -11,5 +11,5 @@ return [
* Put a developper secured mailbox in here * Put a developper secured mailbox in here
* so you can receive email if things go mad * so you can receive email if things go mad
*/ */
'contactsList' => collect(explode(',', env('EXCEPTION_MAIL_LIST')))->all(), 'contactsList' => []
]; ];

View file

@ -1,14 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ruleset name="LDC Laravel" <ruleset name="RealWorld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Created with the PHP Coding Standard Generator. http://edorian.github.com/php-coding-standard-generator/</description>
<arg name="colors"/> <arg name="colors"/>
<arg name="extensions" value="php"/> <arg name="extensions" value="php"/>
<file>src/</file> <file>src/</file>
<rule ref="PSR1" /> <file>tests/</file>
<rule ref="PSR12" /> <description>Created with the PHP Coding Standard Generator. http://edorian.github.com/php-coding-standard-generator/
</description>
<rule ref="Generic.Classes.DuplicateClassName"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement" /> <rule ref="Generic.CodeAnalysis.EmptyStatement" />
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" /> <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall" /> <rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall" />
@ -17,15 +14,18 @@
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier" /> <rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier" />
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter" /> <rule ref="Generic.CodeAnalysis.UnusedFunctionParameter" />
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" /> <rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
<rule ref="Generic.Commenting.DocComment.SpacingBeforeTags"/>
<rule ref="Generic.Commenting.Todo" /> <rule ref="Generic.Commenting.Todo" />
<rule ref="Generic.Commenting.Fixme" /> <rule ref="Generic.Commenting.Fixme" />
<rule ref="Generic.ControlStructures.InlineControlStructure" /> <rule ref="Generic.ControlStructures.InlineControlStructure" />
<rule ref="Generic.Files.ByteOrderMark" /> <rule ref="Generic.Files.ByteOrderMark" />
<rule ref="Generic.Files.LineEndings" /> <rule ref="Generic.Files.LineEndings" />
<rule ref="Generic.Files.LineLength"/> <rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
<property name="absoluteLineLimit" value="0"/>
</properties>
</rule>
<rule ref="Generic.Formatting.DisallowMultipleStatements" /> <rule ref="Generic.Formatting.DisallowMultipleStatements" />
<rule ref="Generic.Formatting.MultipleStatementAlignment"/>
<rule ref="Generic.Formatting.NoSpaceAfterCast" /> <rule ref="Generic.Formatting.NoSpaceAfterCast" />
<rule ref="Generic.Functions.CallTimePassByReference" /> <rule ref="Generic.Functions.CallTimePassByReference" />
<rule ref="Generic.Functions.FunctionCallArgumentSpacing" /> <rule ref="Generic.Functions.FunctionCallArgumentSpacing" />
@ -37,6 +37,7 @@
<rule ref="Generic.PHP.DeprecatedFunctions" /> <rule ref="Generic.PHP.DeprecatedFunctions" />
<rule ref="Generic.PHP.DisallowShortOpenTag" /> <rule ref="Generic.PHP.DisallowShortOpenTag" />
<rule ref="Generic.PHP.ForbiddenFunctions" /> <rule ref="Generic.PHP.ForbiddenFunctions" />
<rule ref="Generic.PHP.LowerCaseConstant" />
<rule ref="Generic.PHP.NoSilencedErrors" /> <rule ref="Generic.PHP.NoSilencedErrors" />
<rule ref="Generic.Strings.UnnecessaryStringConcat" /> <rule ref="Generic.Strings.UnnecessaryStringConcat" />
<rule ref="Generic.WhiteSpace.DisallowTabIndent" /> <rule ref="Generic.WhiteSpace.DisallowTabIndent" />
@ -48,20 +49,8 @@
<rule ref="PEAR.Commenting.InlineComment" /> <rule ref="PEAR.Commenting.InlineComment" />
<rule ref="PSR1.Classes.ClassDeclaration" /> <rule ref="PSR1.Classes.ClassDeclaration" />
<rule ref="PSR1.Files.SideEffects" /> <rule ref="PSR1.Files.SideEffects" />
<rule ref="PSR2.Classes.ClassDeclaration"/>
<rule ref="PSR2.Classes.PropertyDeclaration"/>
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
<rule ref="PSR2.Files.EndFileNewline"/>
<rule ref="PSR2.Methods.MethodDeclaration"/>
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
<rule ref="PSR2.Namespaces.UseDeclaration"/>
<rule ref="Squiz.PHP.CommentedOutCode" /> <rule ref="Squiz.PHP.CommentedOutCode" />
<rule ref="Squiz.PHP.DisallowMultipleAssignments">
<exclude name="Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure" />
</rule>
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops" /> <rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops" />
<rule ref="Squiz.PHP.DiscouragedFunctions"> <rule ref="Squiz.PHP.DiscouragedFunctions">
<properties> <properties>
<property name="error" value="true" /> <property name="error" value="true" />
@ -76,11 +65,10 @@
<rule ref="Squiz.Scope.MemberVarScope" /> <rule ref="Squiz.Scope.MemberVarScope" />
<rule ref="Squiz.Scope.MethodScope" /> <rule ref="Squiz.Scope.MethodScope" />
<rule ref="Squiz.Scope.StaticThisUsage" /> <rule ref="Squiz.Scope.StaticThisUsage" />
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/> <rule ref="Squiz.WhiteSpace.MemberVarSpacing" />
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/> <rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<rule ref="Squiz.WhiteSpace.MemberVarSpacing">
<properties> <properties>
<property name="spacingBeforeFirst " value="false"/> <property name="ignoreNewlines" value="true"/>
</properties> </properties>
</rule> </rule>
<rule ref="Squiz.WhiteSpace.OperatorSpacing"> <rule ref="Squiz.WhiteSpace.OperatorSpacing">
@ -88,39 +76,12 @@
<property name="ignoreNewlines" value="true"/> <property name="ignoreNewlines" value="true"/>
</properties> </properties>
</rule> </rule>
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing" /> <rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing" />
<rule ref="Squiz.WhiteSpace.SemicolonSpacing" /> <rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
<rule ref="Squiz.Commenting.BlockComment">
<exclude name="Squiz.Commenting.BlockComment.WrongStart" />
</rule>
<rule ref="Squiz.Commenting.ClassComment">
<exclude name="Squiz.Commenting.ClassComment.Missing" />
<exclude name="Squiz.Commenting.ClassComment.TagNotAllowed" />
</rule>
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
<rule ref="Squiz.Commenting.FunctionComment">
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" />
</rule>
<rule ref="Squiz.Commenting.FunctionCommentThrowTag"/>
<rule ref="Squiz.Commenting.InlineComment">
<exclude name="Squiz.Commenting.InlineComment.DocBlock" />
</rule>
<rule ref="Squiz.Commenting.LongConditionClosingComment">
<exclude name="Squiz.Commenting.LongConditionClosingComment.SpacingBefore" />
</rule>
<rule ref="Squiz.Commenting.PostStatementComment"/>
<rule ref="Squiz.Commenting.VariableComment"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse" />
<!-- For Laravel migrations --> <!-- For Laravel migrations -->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace"> <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>*/database/migrations/*</exclude-pattern> <exclude-pattern>*/database/migrations/*</exclude-pattern>
</rule> </rule>
</ruleset> </ruleset>

View file

@ -2,6 +2,8 @@
[![Latest Version on Packagist][ico-version]][link-packagist] [![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads] [![Total Downloads][ico-downloads]][link-downloads]
[![Build Status][ico-travis]][link-travis]
[![StyleCI][ico-styleci]][link-styleci]
Handles exceptions and send email when it does happen Handles exceptions and send email when it does happen
It does send you a mail with anonymized debug data It does send you a mail with anonymized debug data
@ -16,26 +18,23 @@ $ composer require kwaadpepper/exception-handler
## Usage ## Usage
- `php artisan handler:install` 1 - php artisan handler:install
- Change configuration in `config/exception-handler.php` if needed. 2 - Change configuration in config/exception-handler.php
- Put at least your team email in the above file in `contactsList` array or using `.env` put a list in `EXCEPTION_MAIL_LIST`. You can add emails separated with `,` like `admin1@email.com,admin2@email.com` 3 - put at least your team email in the above file in `contactsList` array
You can uninstall it by using `php artisan handler:remove` or just revert changes in Exception/Handler.php You can uninstall it by using php artisan handler:remove or juste revert changes in Exception/Handler.php
## Change log ## Change log
Please see the [changelog](changelog.md) for more information on what has changed recently. Please see the [changelog](changelog.md) for more information on what has changed recently.
# Todo
- Add other transmission possibilities (other than mail)
## Security ## Security
If you discover any security related issues, please email `github@jeremydev.ovh` instead of using the issue tracker. If you discover any security related issues, please email github@jeremydev.ovh instead of using the issue tracker.
## Credits ## Credits
- [Jérémy Munsch][link-author] - [Jérémy Munsch][link-author]
- [All Contributors][link-contributors]
## License ## License

View file

@ -5,7 +5,6 @@
]) }} ]) }}
{{ __('check_trace') }} {{ __('check_trace') }}
{{ $ename }}
{{ $emessage }} {{ $emessage }}
{{ __('uri') }} : {{ $uri }} {{ __('uri') }} : {{ $uri }}
{{ __('date') }} : {{ date('Y-m-d H:i:s') }} {{ __('date') }} : {{ date('Y-m-d H:i:s') }}

View file

@ -11,8 +11,7 @@
<h1>{{ __('error_occured_in_app', ['appName' => $appName]) }}</h1> <h1>{{ __('error_occured_in_app', ['appName' => $appName]) }}</h1>
<p>{{ __('check_trace') }}</p> <p>{{ __('check_trace') }}</p>
<h2>{{ $ename }}</h2> <h2>{{ $emessage }}</h2>
<h3>{!! nl2br(strip_tags(e($emessage))) !!}</h3>
<p>{{ __('uri') }} : {{ $uri }}</p> <p>{{ __('uri') }} : {{ $uri }}</p>
<p>{{ __('date') }} : {{ date('Y-m-d H:i:s') }}</p> <p>{{ __('date') }} : {{ date('Y-m-d H:i:s') }}</p>
<p>{{ __('code') }} : {{ $code }}</p> <p>{{ __('code') }} : {{ $code }}</p>

View file

@ -7,6 +7,7 @@ use Illuminate\Support\Facades\File;
class InstallHandler extends Command class InstallHandler extends Command
{ {
/** /**
* The name and signature of the console command. * The name and signature of the console command.
* *

View file

@ -7,6 +7,7 @@ use Illuminate\Support\Facades\File;
class RemoveHandler extends Command class RemoveHandler extends Command
{ {
/** /**
* The name and signature of the console command. * The name and signature of the console command.
* *

View file

@ -6,6 +6,7 @@ use Illuminate\Support\ServiceProvider;
class ExceptionHandlerServiceProvider extends ServiceProvider class ExceptionHandlerServiceProvider extends ServiceProvider
{ {
protected $commands = [ protected $commands = [
'Kwaadpepper\ExceptionHandler\Console\Commands\InstallHandler', 'Kwaadpepper\ExceptionHandler\Console\Commands\InstallHandler',
'Kwaadpepper\ExceptionHandler\Console\Commands\RemoveHandler' 'Kwaadpepper\ExceptionHandler\Console\Commands\RemoveHandler'
@ -29,7 +30,7 @@ class ExceptionHandlerServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->mergeConfigFrom( $this->mergeConfigFrom(
__DIR__ . '/../config/exception-handler.php', sprintf('%s/../config/exception-handler.php', __DIR__),
'exception-handler' 'exception-handler'
); );
$this->commands($this->commands); $this->commands($this->commands);

View file

@ -2,13 +2,17 @@
namespace Kwaadpepper\ExceptionHandler\Exceptions; namespace Kwaadpepper\ExceptionHandler\Exceptions;
use Closure;
use Exception;
use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Container\Container;
use Illuminate\Foundation\Exceptions\Handler; use Illuminate\Foundation\Exceptions\Handler;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
use Throwable;
class ExceptionHandler extends Handler class ExceptionHandler extends Handler
{ {
/** /**
* Create a new exception handler instance. * Create a new exception handler instance.
* *
@ -18,73 +22,47 @@ class ExceptionHandler extends Handler
public function __construct(Container $container) public function __construct(Container $container)
{ {
parent::__construct($container); parent::__construct($container);
if (\strpos(app()->version(), '8') === 0) {
$this->reportable($this->reportExceptionByEmail()); $this->reportable($this->reportExceptionByEmail());
} }
}
/** /**
* Report or log an exception. * Report or log an exception.
* *
* @param \Throwable $e * @param \Throwable $exception
* @return void * @return void
*
* @throws \Exception
*/ */
public function report(\Throwable $e) public function report(Throwable $e)
{ {
if (get_class($e) == RedirectTo::class) { if (get_class($e) == RedirectTo::class) {
abort(redirect($e->url)); abort(redirect($e->url));
} }
if (
\strpos(app()->version(), '8') !== 0 and
!$this->reportExceptionByEmail()($e)
) {
return false;
}
parent::report($e); parent::report($e);
} }
/**
* Manually send exception by email
*
* @param \Throwable $e
* @return void
*/
public static function sendExceptionByEmailStatic(\Throwable $e)
{
app(self::class)->sendExceptionByEmail($e);
}
/**
* Manually send exception by email
*
* @param \Throwable $e
* @return void
*/
public function sendExceptionByEmail(\Throwable $e)
{
$this->reportExceptionByEmail()($e);
}
/** /**
* Report sending mail closure * Report sending mail closure
* *
* @return \Closure * @return Closure
*/ */
private function reportExceptionByEmail(): \Closure private function reportExceptionByEmail(): Closure
{ {
return function (\Throwable $e) { return function (Throwable $e) {
$dest = config('exception-handler.contactsList', config('mail.from.address'));
try {
if ($dest and config('exception-handler.enableMaiLog')) {
if ($this->shouldntReport($e)) { if ($this->shouldntReport($e)) {
return false; return false;
} }
// * Ignore NoContactException.
if ($e instanceof NoContactException) {
Log::critical($e->getMessage());
return false;
}
$dest = \collect(config('exception-handler.contactsList', config('mail.from.address')))->filter();
try {
if (!config('exception-handler.enableMaiLog')) {
return false;
}
if (!$dest->count()) {
throw new NoContactException(
'No contact in `EXCEPTION_MAIL_LIST` nor `exception-handler.contactsList` config',
0,
$e
);
}
Mail::send([ Mail::send([
'html' => 'exception-handler::emails.exception', 'html' => 'exception-handler::emails.exception',
'text' => 'exception-handler::emails.exception-plain' 'text' => 'exception-handler::emails.exception-plain'
@ -92,10 +70,9 @@ class ExceptionHandler extends Handler
'appName' => config('app.name'), 'appName' => config('app.name'),
'code' => $e->getCode(), 'code' => $e->getCode(),
'line' => $e->getLine(), 'line' => $e->getLine(),
'ename' => \get_class($e), 'emessage' => $this->getAnonymizedMessage($e->getMessage()),
'emessage' => self::getAnonymizedMessage($e->getMessage()),
'file' => str_replace(\realpath(\sprintf('%s/../', \app_path())), '', $e->getFile()), 'file' => str_replace(\realpath(\sprintf('%s/../', \app_path())), '', $e->getFile()),
'stackTrace' => self::getAnonymizedStackTrace($e), 'stackTrace' => $this->getAnonymizedStackTrace($e),
'uri' => app()->runningInConsole() ? 'uri' => app()->runningInConsole() ?
'CONSOLE' : ( 'CONSOLE' : (
(request() and request()->fullUrl()) ? (request() and request()->fullUrl()) ?
@ -103,14 +80,16 @@ class ExceptionHandler extends Handler
], function ($m) use ($dest) { ], function ($m) use ($dest) {
/** @var \Illuminate\Mail\Message $m */ /** @var \Illuminate\Mail\Message $m */
$m->to( $m->to(
$dest->all(), $dest,
sprintf('%s Exception Handler', config('app.name')) sprintf('%s Exception Handler', config('app.name'))
)->subject('Need help !, an error occured in your application, please check Logs ASAP'); )->subject('Need help !, an error occured in your application, please check Logs ASAP');
}); });
} catch (\Error $reportE) { }
parent::report($e); } catch (Exception $e) {
Log::critical('Handler could not send Exception email', ['exception' => $reportE]); Log::critical('Handler could not send Exception email', ['exception' => $e]);
}//end try } finally {
return true;
}
}; };
} }
@ -120,22 +99,19 @@ class ExceptionHandler extends Handler
* @param string $message * @param string $message
* @return string * @return string
*/ */
private static function getAnonymizedMessage(string $message): string private function getAnonymizedMessage(string $message): string
{ {
$message = \preg_replace('/^(.*)( \(SQL:.*\))$/', '$1', $message) ?? $message; $message = \preg_replace('/^(.*)( \(SQL:.*\))$/', '$1', $message) ?? $message;
if ($sqlPos = \strpos($message, 'to use near')) {
$message = \mb_strcut($message, 0, $sqlPos);
}
return $message; return $message;
} }
/** /**
* Anonymize stack trace * Anonymize stack trace
* *
* @param \Throwable $e * @param \Exception $e
* @return string * @return string
*/ */
private static function getAnonymizedStackTrace(\Throwable $e): string private function getAnonymizedStackTrace(\Exception $e): string
{ {
$projectPath = \realpath(\sprintf('%s/../', \app_path())); $projectPath = \realpath(\sprintf('%s/../', \app_path()));
$traceStack = $e->getTrace(); $traceStack = $e->getTrace();
@ -146,37 +122,12 @@ class ExceptionHandler extends Handler
$traceStr .= \sprintf( $traceStr .= \sprintf(
'#%s %s(%d): ', '#%s %s(%d): ',
$stackStage, $stackStage,
str_replace($projectPath, '', $stack['file'] ?? ''), str_replace($projectPath, '', $stack['file']),
$stack['line'] ?? '' $stack['line']
); );
if (isset($stack['class'])) {
$traceStr .= "{$stack['class']}->{$stack['function']}("; $traceStr .= "{$stack['class']}->{$stack['function']}(";
if (isset($stack['args'])) {
$traceStr .= self::handleArgs($stack);
}
$traceStr .= ")\n";
} elseif (isset($stack['function'])) {
$traceStr .= "{$stack['function']}(";
if (isset($stack['args'])) {
$traceStr .= self::handleArgs($stack);
}
$traceStr .= ")\n";
}
} //end foreach
$maxStackStage++;
$traceStr .= "#$maxStackStage {main}";
return $traceStr;
}
/**
* Handle Args
*
* @param array $stack
* @return string
*/
private static function handleArgs(array $stack): string
{
$traceArgs = ''; $traceArgs = '';
if (isset($stack['args'])) {
$argsCount = count($stack['args']); $argsCount = count($stack['args']);
for ($i = 0; $i < $argsCount; $i++) { for ($i = 0; $i < $argsCount; $i++) {
$type = \gettype($stack['args'][$i]); $type = \gettype($stack['args'][$i]);
@ -195,6 +146,12 @@ class ExceptionHandler extends Handler
} }
$traceArgs .= ($i !== ($argsCount - 1) ? ',' : ''); $traceArgs .= ($i !== ($argsCount - 1) ? ',' : '');
} }
return $traceArgs; $traceStr .= $traceArgs;
}
$traceStr .= ")\n";
}
$maxStackStage++;
$traceStr .= "#$maxStackStage {main}";
return $traceStr;
} }
} }

View file

@ -1,7 +0,0 @@
<?php
namespace Kwaadpepper\ExceptionHandler\Exceptions;
class NoContactException extends \RuntimeException
{
}