<?php

namespace Fifa\ConnectServiceBus\Sdk\ExceptionHandler;

use Fifa\ConnectServiceBus\Sdk\Api\ApiException;

class ExceptionHandler
{
    /**
     * Method that wraps Exception in FifaConnectServiceBusSdkException 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;
    }
}