TenantAtlas/apps/platform/app/Services/Graph/GraphErrorMapper.php
2026-04-08 09:33:16 +02:00

24 lines
524 B
PHP

<?php
namespace App\Services\Graph;
use Throwable;
class GraphErrorMapper
{
public static function fromThrowable(Throwable $throwable, array $context = []): GraphException
{
if ($throwable instanceof GraphException) {
return $throwable;
}
$code = (int) ($throwable->getCode() ?: 0);
return new GraphException(
$throwable->getMessage(),
$code > 0 ? $code : null,
$context + ['exception' => get_class($throwable)]
);
}
}