mirror of
https://github.com/cydrobolt/polr.git
synced 2024-11-09 19:52:28 +01:00
Catch Exceptions thrown by StatHelper and throw an ApiException
This commit is contained in:
parent
fc056a9364
commit
eb8b27a341
@ -46,7 +46,12 @@ class ApiAnalyticsController extends ApiController {
|
||||
throw new ApiException('ACCESS_DENIED', 'Unauthorized.', 401, $response_type);
|
||||
}
|
||||
|
||||
try {
|
||||
$stats = new StatsHelper($link->id, $left_bound, $right_bound);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
throw new ApiException('ANALYTICS_ERROR', $e->getMessage(), 400, $response_type);
|
||||
}
|
||||
|
||||
if ($stats_type == 'day') {
|
||||
$fetched_stats = $stats->getDayStats();
|
||||
|
@ -1,4 +1,6 @@
|
||||
## API Error Text Codes
|
||||
To diagnose an unexpected or unhandled error, turn on the `APP_DEBUG` flag by setting
|
||||
it to `true` in `.env`
|
||||
|
||||
`SERVER_ERROR`: A generic, unhandled error has occured.
|
||||
|
||||
@ -17,3 +19,5 @@
|
||||
`AUTH_ERROR`: An error occured while attempting to authenticate the user to the API.
|
||||
|
||||
`QUOTA_EXCEEDED`: User's API usage has exceeded alloted quota.
|
||||
|
||||
`ANALYTICS_ERROR`: Invalid bounds or unexpected error while fetching analytics data.
|
||||
|
Loading…
Reference in New Issue
Block a user