<?php

namespace Fifa\ConnectId\Sdk\ExceptionHandler;

use Fifa\ConnectId\Sdk\Api\ApiException;

class ExceptionHandler
{
    /**
     * Method that wraps Exception in FifaConnectIdException if it's ApiException, otherwise returns the same exception as passed
     *
     * @param mixed $exception
     * @param $handlers - objects implementing HandlerInterface
     */
    public static function create($exception, ...$handlers)
    {
        return $exception instanceof ApiException
            ? ApiExceptionHandler::createException($exception, ...$handlers)
            : $exception;
    }

}