diff options
-rw-r--r-- | app/Http/Controllers/Api/ApiAnalyticsController.php | 7 | ||||
-rw-r--r-- | docs/developer-guide/api_errors.md | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/app/Http/Controllers/Api/ApiAnalyticsController.php b/app/Http/Controllers/Api/ApiAnalyticsController.php index 3908307..c1bc5ad 100644 --- a/app/Http/Controllers/Api/ApiAnalyticsController.php +++ b/app/Http/Controllers/Api/ApiAnalyticsController.php @@ -46,7 +46,12 @@ class ApiAnalyticsController extends ApiController { throw new ApiException('ACCESS_DENIED', 'Unauthorized.', 401, $response_type); } - $stats = new StatsHelper($link->id, $left_bound, $right_bound); + 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(); diff --git a/docs/developer-guide/api_errors.md b/docs/developer-guide/api_errors.md index 62f5585..adbe5e8 100644 --- a/docs/developer-guide/api_errors.md +++ b/docs/developer-guide/api_errors.md @@ -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. |