CoreFiles by mySites.guru
InvalidParameterExceptionHandler.php47 lines, 1,081 bytes, from Joomla_5.4.2-Stable-Full_Package.zip
Raw History Compare with 5.4.1
md5
0ba9d588d3fef61429ed12c27d28925b
sha1
03849da4a712a33ca1b2a18fe528ef2e75dbef16
sha256
0a0dfa581620208a4f0562b6cc07974cd25a4160248b98d1a162c3428ae5f313
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Error\JsonApi;

use Tobscure\JsonApi\Exception\Handler\ResponseBag;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Handler for invalid param
 *
 * @since  4.0.0
 */
class InvalidParameterExceptionHandler extends \Tobscure\JsonApi\Exception\Handler\InvalidParameterExceptionHandler
{
    /**
     * Handle the provided exception.
     *
     * @param   \Exception  $e  The exception being handled
     *
     * @return  \Tobscure\JsonApi\Exception\Handler\ResponseBag
     *
     * @since  4.0.0
     */
    public function handle(\Exception $e)
    {
        $status = 400;
        $error  = ['title' => $e->getMessage()];

        $code = $e->getCode();

        if ($code) {
            $error['code'] = $code;
        }

        return new ResponseBag($status, [$error]);
    }
}

The same content is in 133 releases, Joomla 5.1.0-beta1 to 6.2.1-rc1. See them all, or every version of this file.