protected function getHttpStatusCode(Exception $exception): int
    {
        if ($exception instanceof ApiException) {
            return $exception->apiMessage->getHttpStatusCode();
        }

        if ($exception instanceof HttpExceptionInterface && method_exists($exception, 'getStatusCode')) {
            return $exception->getStatusCode();
        }

        return 500;
    }