for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the FreshCommonApiBundle
*
* (c) Artem Henvald <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Fresh\CommonApiBundle\Helper;
use Fresh\CommonApiBundle\Exception\ServerInternalErrorException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
/**
* ExceptionHelperTrait.
* @author Artem Henvald <[email protected]>
trait ExceptionHelperTrait
{
* @param string $message
* @param \Exception|null $previous
* @return BadRequestHttpException
protected function createBadRequestException(string $message = 'Wrong Request', ?\Exception $previous = null): BadRequestHttpException
return new BadRequestHttpException($message, $previous);
}
* @return UnauthorizedHttpException
protected function createUnauthorizedException(string $message = 'Invalid Credentials', ?\Exception $previous = null): UnauthorizedHttpException
return new UnauthorizedHttpException('Basic realm="My Realm"', $message, $previous);
* @return ServerInternalErrorException
protected function createInternalServerErrorException(string $message = 'Internal Server Error', ?\Exception $previous = null): ServerInternalErrorException
return new ServerInternalErrorException($message, $previous);