ExceptionFOSRestController.php 661 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<?php
namespace App\Controller;

use FOS\RestBundle\Controller\FOSRestController;
use App\Exception\BadRequestDataException;

/**
 * Class ExceptionFOSRestController passes the error messages to FOSRest-registered exception.
 *
 * @package SGalinski\TypoScriptBackendBundle\Controller
 */
abstract class ExceptionFOSRestController extends FOSRestController
{
    /**
     * Makes response from given exception.
     *
     * @param \Exception $exception
     * @throws BadRequestDataException
     */
    protected function throwFosrestSupportedException(\Exception $exception)
    {
        throw new BadRequestDataException($exception->getMessage());
    }
}