2016-09-26 00:22:33 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* This file is part of RSS-Bridge, a PHP project capable of generating RSS and
|
|
|
|
* Atom feeds for websites that don't have one.
|
|
|
|
*
|
|
|
|
* For the full license information, please view the UNLICENSE file distributed
|
|
|
|
* with this source code.
|
|
|
|
*
|
2022-07-01 16:10:30 +03:00
|
|
|
* @package Core
|
|
|
|
* @license http://unlicense.org/ UNLICENSE
|
|
|
|
* @link https://github.com/rss-bridge/rss-bridge
|
2018-11-16 23:48:59 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws an exception when called.
|
|
|
|
*
|
2018-11-18 18:53:21 +03:00
|
|
|
* @throws \Exception when called
|
2018-11-16 23:48:59 +03:00
|
|
|
* @param string $message The error message
|
|
|
|
* @param int $code The HTTP error code
|
|
|
|
* @link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes List of HTTP
|
|
|
|
* status codes
|
|
|
|
*/
|
2022-07-01 16:10:30 +03:00
|
|
|
function returnError($message, $code)
|
|
|
|
{
|
|
|
|
throw new \Exception($message, $code);
|
2016-09-26 00:22:33 +03:00
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Returns HTTP Error 400 (Bad Request) when called.
|
|
|
|
*
|
|
|
|
* @param string $message The error message
|
|
|
|
*/
|
2022-07-01 16:10:30 +03:00
|
|
|
function returnClientError($message)
|
|
|
|
{
|
|
|
|
returnError($message, 400);
|
2016-09-26 00:22:33 +03:00
|
|
|
}
|
|
|
|
|
2018-11-16 23:48:59 +03:00
|
|
|
/**
|
|
|
|
* Returns HTTP Error 500 (Internal Server Error) when called.
|
|
|
|
*
|
|
|
|
* @param string $message The error message
|
|
|
|
*/
|
2022-07-01 16:10:30 +03:00
|
|
|
function returnServerError($message)
|
|
|
|
{
|
|
|
|
returnError($message, 500);
|
2016-09-26 00:22:33 +03:00
|
|
|
}
|