core: Add an option to return errors in different formats (#1071)
Bridge errors are currently included as part of the feed to notify users about erroneous bridges (before that, bridges silently failed). This solution, however, can produce a high load of error messages if servers are down (see #994 for more details). Admins may also not want to include error messages in feeds in order to keep those kind of problems away from users or simply to silently fail by choice. This commit adds a new configuration section "error" with one option "output" which can be set to following values: "feed": To include error messages in the feed (default) "http": To return a HTTP header for each error "none": To disable error reporting Note that errors are always logged to 'error.log' independent of the settings above. Closes #1066
This commit is contained in:
parent
a0afe36d56
commit
e8536ac1b2
3 changed files with 68 additions and 46 deletions
|
@ -146,6 +146,7 @@ class DisplayAction extends ActionAbstract {
|
||||||
} catch(Error $e) {
|
} catch(Error $e) {
|
||||||
error_log($e);
|
error_log($e);
|
||||||
|
|
||||||
|
if(Configuration::getConfig('error', 'output') === 'feed') {
|
||||||
$item = new \FeedItem();
|
$item = new \FeedItem();
|
||||||
|
|
||||||
// Create "new" error message every 24 hours
|
// Create "new" error message every 24 hours
|
||||||
|
@ -178,9 +179,14 @@ class DisplayAction extends ActionAbstract {
|
||||||
$item->setContent(buildBridgeException($e, $bridge));
|
$item->setContent(buildBridgeException($e, $bridge));
|
||||||
|
|
||||||
$items[] = $item;
|
$items[] = $item;
|
||||||
|
} elseif(Configuration::getConfig('error', 'output') === 'http') {
|
||||||
|
header('Content-Type: text/html', true, $e->getCode());
|
||||||
|
die(buildTransformException($e, $bridge));
|
||||||
|
}
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
error_log($e);
|
error_log($e);
|
||||||
|
|
||||||
|
if(Configuration::getConfig('error', 'output') === 'feed') {
|
||||||
$item = new \FeedItem();
|
$item = new \FeedItem();
|
||||||
|
|
||||||
// Create "new" error message every 24 hours
|
// Create "new" error message every 24 hours
|
||||||
|
@ -203,6 +209,10 @@ class DisplayAction extends ActionAbstract {
|
||||||
$item->setContent(buildBridgeException($e, $bridge));
|
$item->setContent(buildBridgeException($e, $bridge));
|
||||||
|
|
||||||
$items[] = $item;
|
$items[] = $item;
|
||||||
|
} elseif(Configuration::getConfig('error', 'output') === 'http') {
|
||||||
|
header('Content-Type: text/html', true, $e->getCode());
|
||||||
|
die(buildTransformException($e, $bridge));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store data in cache
|
// Store data in cache
|
||||||
|
|
|
@ -61,6 +61,15 @@ username = ""
|
||||||
; Use a strong password to prevent others from guessing your login!
|
; Use a strong password to prevent others from guessing your login!
|
||||||
password = ""
|
password = ""
|
||||||
|
|
||||||
|
[error]
|
||||||
|
|
||||||
|
; Defines how error messages are returned by RSS-Bridge
|
||||||
|
;
|
||||||
|
; "feed" = As part of the feed (default)
|
||||||
|
; "http" = As HTTP error message
|
||||||
|
; "none" = No errors are reported
|
||||||
|
output = "feed"
|
||||||
|
|
||||||
; --- Cache specific configuration ---------------------------------------------
|
; --- Cache specific configuration ---------------------------------------------
|
||||||
|
|
||||||
[SQLiteCache]
|
[SQLiteCache]
|
||||||
|
|
|
@ -201,6 +201,9 @@ final class Configuration {
|
||||||
&& !filter_var(self::getConfig('admin', 'email'), FILTER_VALIDATE_EMAIL))
|
&& !filter_var(self::getConfig('admin', 'email'), FILTER_VALIDATE_EMAIL))
|
||||||
self::reportConfigurationError('admin', 'email', 'Is not a valid email address');
|
self::reportConfigurationError('admin', 'email', 'Is not a valid email address');
|
||||||
|
|
||||||
|
if(!is_string(self::getConfig('error', 'output')))
|
||||||
|
self::reportConfigurationError('error', 'output', 'Is not a valid String');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue