2016-09-25 23:22:33 +02:00
|
|
|
<?php
|
2018-11-16 21:48:59 +01: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.
|
|
|
|
*
|
|
|
|
* @package Core
|
|
|
|
* @license http://unlicense.org/ UNLICENSE
|
|
|
|
* @link https://github.com/rss-bridge/rss-bridge
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Throws an exception when called.
|
|
|
|
*
|
|
|
|
* @throws \HttpException when called
|
|
|
|
* @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
|
|
|
|
*/
|
2016-09-25 23:22:33 +02:00
|
|
|
function returnError($message, $code){
|
2016-11-09 19:10:40 +01:00
|
|
|
throw new \HttpException($message, $code);
|
2016-09-25 23:22:33 +02:00
|
|
|
}
|
|
|
|
|
2018-11-16 21:48:59 +01:00
|
|
|
/**
|
|
|
|
* Returns HTTP Error 400 (Bad Request) when called.
|
|
|
|
*
|
|
|
|
* @param string $message The error message
|
|
|
|
*/
|
2016-09-25 23:22:33 +02:00
|
|
|
function returnClientError($message){
|
2016-11-09 19:10:40 +01:00
|
|
|
returnError($message, 400);
|
2016-09-25 23:22:33 +02:00
|
|
|
}
|
|
|
|
|
2018-11-16 21:48:59 +01:00
|
|
|
/**
|
|
|
|
* Returns HTTP Error 500 (Internal Server Error) when called.
|
|
|
|
*
|
|
|
|
* @param string $message The error message
|
|
|
|
*/
|
2016-09-25 23:22:33 +02:00
|
|
|
function returnServerError($message){
|
2016-11-09 19:10:40 +01:00
|
|
|
returnError($message, 500);
|
2016-09-25 23:22:33 +02:00
|
|
|
}
|