Skip to content

Commit

Permalink
Deduce log level from ClientAware, not GraphpinatorBase
Browse files Browse the repository at this point in the history
  • Loading branch information
peldax committed Nov 12, 2023
1 parent f83cf2c commit 6093352
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/ErrorHandlingMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types = 1);

namespace Graphpinator;

enum ErrorHandlingMode
{
// Catch all exceptions. ClientAware exceptions returns corresponding result, unknown exceptions throw an "Unknown error".
case ALL;
// Catch ClientAware exceptions and return corresponding result, unknown exceptions are rethrown.
case CLIENT_AWARE;
// Rethrow all exceptions.
case NONE;

public static function fromBool(bool $value) : self
{
return $value
? self::ALL
: self::NONE;
}
}
2 changes: 1 addition & 1 deletion src/Graphpinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private static function getLogMessage(\Throwable $exception) : string

private static function getLogLevel(\Throwable $exception) : string
{
if ($exception instanceof \Graphpinator\Exception\GraphpinatorBase) {
if ($exception instanceof \Graphpinator\Exception\ClientAware) {
return $exception->isOutputable()
? \Psr\Log\LogLevel::INFO
: \Psr\Log\LogLevel::ERROR;
Expand Down

0 comments on commit 6093352

Please sign in to comment.