Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cydrobolt/polr.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChaoyi Zha <summermontreal@gmail.com>2017-03-21 00:34:09 +0300
committerChaoyi Zha <summermontreal@gmail.com>2017-03-21 00:34:09 +0300
commiteb8b27a3413c32c696591d51c597b77680b5406c (patch)
tree36d370c48a6334b1fb6ce006ffa5b68e09865624
parentfc056a9364b6bcb0116d4407d002f75a768e3152 (diff)
Catch Exceptions thrown by StatHelper and throw an ApiException
-rw-r--r--app/Http/Controllers/Api/ApiAnalyticsController.php7
-rw-r--r--docs/developer-guide/api_errors.md4
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.