display better exception for traffic results if admin has no customers

This commit is contained in:
envoyr
2022-10-25 13:37:33 +02:00
parent 3acc5457b2
commit 34d5583333
4 changed files with 6 additions and 1 deletions

View File

@@ -37,6 +37,9 @@ if ($page == 'overview' || $page == 'customers') {
try { try {
$context = Traffic::getCustomerStats($userinfo, $range); $context = Traffic::getCustomerStats($userinfo, $range);
} catch (Exception $e) { } catch (Exception $e) {
if ($e->getCode() === 405) {
Response::dynamicError(lng('traffic.nocustomers'));
}
Response::dynamicError($e->getMessage()); Response::dynamicError($e->getMessage());
} }

View File

@@ -470,7 +470,7 @@ abstract class ApiCommand extends ApiParameter
* *
* @param string $customer_hide_option * @param string $customer_hide_option
* optional, when called as customer, some options might be hidden due to the * optional, when called as customer, some options might be hidden due to the
* panel.customer_hide_options ettings * panel.customer_hide_options settings
* *
* @return array * @return array
* @throws Exception * @throws Exception

View File

@@ -2117,6 +2117,7 @@ Vielen Dank, Ihr Administrator',
'http' => 'HTTP', 'http' => 'HTTP',
'ftp' => 'FTP', 'ftp' => 'FTP',
'mail' => 'Mail', 'mail' => 'Mail',
'nocustomers' => 'Es wird mindestens ein Kunde benötigt um die Traffic Statistiken anzuzeigen.',
], ],
'translator' => '', 'translator' => '',
'update' => [ 'update' => [

View File

@@ -2243,6 +2243,7 @@ Yours sincerely, your administrator',
'http' => 'HTTP', 'http' => 'HTTP',
'ftp' => 'FTP', 'ftp' => 'FTP',
'mail' => 'Mail', 'mail' => 'Mail',
'nocustomers' => 'You need at least one customer to view the traffic reports.',
], ],
'translator' => '', 'translator' => '',
'update' => [ 'update' => [