1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-04 15:47:32 +02:00

[BridgeAbstract] Add returnClientError and returnServerError

LogMANOriginal
2016-08-17 14:55:35 +02:00
parent 15c8559272
commit ea175c8b7a

@@ -189,10 +189,14 @@ All bridges extend from `BridgeAbstract` and therefore are able to make use of f
Following functions should be used for good practice and will support you with your bridge : Following functions should be used for good practice and will support you with your bridge :
* [`returnError`](#the-returnerror-function) * [`returnError`](#the-returnerror-function)
* [`returnClientError`](#the-returnclienterror-function)
* [`returnServerError`](#the-returnservererror-function)
* [`file_get_html`](#the-file_get_html-function) * [`file_get_html`](#the-file_get_html-function)
## The `returnError` function ## The `returnError` function
**Notice:** Whenever possible make use of [`returnClientError`](#the-returnclienterror-function) or [`returnServerError`](#the-returnservererror-function)
This function aborts execution of the current bridge and returns the given error message with the provided error number : This function aborts execution of the current bridge and returns the given error message with the provided error number :
```PHP ```PHP
@@ -201,6 +205,26 @@ $this->returnError('Your error message', 404)
Check the [list of error codes](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for applicable error numbers. Check the [list of error codes](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for applicable error numbers.
## The `returnClientError` function
This function aborts execution of the current bridge and returns the given error message with error code **400**:
```PHP
$this->returnClientError('Your error message')
```
Use this function when the user provided invalid parameter or a required parameter is missing.
## The `returnServerError` function
This function aborts execution of the current bridge and returns the given error message with error code **500**:
```PHP
$this->returnServerError('Your error message')
```
Use this function when a problem occurs that has nothing to do with the parameters provided by the user. (like: Host service gone missing, empty data received, etc...)
## The `file_get_html` function ## The `file_get_html` function
This function is a wrapper around the [simple_html_dom](http://simplehtmldom.sourceforge.net/) [file_get_html](http://simplehtmldom.sourceforge.net/manual_api.htm#api) function in order to provide context by design. It is considered good practice to use this function. This function is a wrapper around the [simple_html_dom](http://simplehtmldom.sourceforge.net/) [file_get_html](http://simplehtmldom.sourceforge.net/manual_api.htm#api) function in order to provide context by design. It is considered good practice to use this function.