CoreFiles by mySites.guru
InvalidParameterExceptionHandler.php46 lines, 948 bytes, from Joomla_4.0.0-beta1-Beta-Full_Package.zip
Raw History Compare with 3.9.0-beta4
md5
be69d23850dcc29dc7dd769265b09f13
sha1
3b46958eec5f52b770641138c217e9d9f43acd1e
sha256
f1d7300a8a05be537377a16b336f9aea4d85565464c95ca5d5a79c5b81407eb4
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\CMS\Error\JsonApi;

defined('JPATH_PLATFORM') or die;

use Exception;
use Tobscure\JsonApi\Exception\Handler\ResponseBag;

/**
 * Handler for invalid param
 *
 * @since  4.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 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.