瀏覽代碼

Handler.php add http status code in comment

Yong 2 年之前
父節點
當前提交
3a47ea90cf
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5
    5
      app/Exceptions/Handler.php

+ 5
- 5
app/Exceptions/Handler.php 查看文件

57
 
57
 
58
     public function handleApiException(Throwable $exception)
58
     public function handleApiException(Throwable $exception)
59
     {
59
     {
60
-        // Route Not Found
60
+        // Route Not Found 404
61
         if ($exception instanceof RouteNotFoundException) {
61
         if ($exception instanceof RouteNotFoundException) {
62
             return $this->apiExceptionResponse($exception, Response::HTTP_NOT_FOUND, config('response-message.router_failed'));
62
             return $this->apiExceptionResponse($exception, Response::HTTP_NOT_FOUND, config('response-message.router_failed'));
63
         }
63
         }
64
 
64
 
65
-        // Not Found
65
+        // Not Found 404
66
         if ($exception instanceof NotFoundHttpException) {
66
         if ($exception instanceof NotFoundHttpException) {
67
             $message = $exception->getMessage() ?: config('response-message.not_found');
67
             $message = $exception->getMessage() ?: config('response-message.not_found');
68
             return $this->apiExceptionResponse($exception, Response::HTTP_NOT_FOUND, $message);
68
             return $this->apiExceptionResponse($exception, Response::HTTP_NOT_FOUND, $message);
69
         }
69
         }
70
 
70
 
71
-        // Model Not Found
71
+        // Model Not Found 500
72
         if ($exception instanceof ModelNotFoundException) {
72
         if ($exception instanceof ModelNotFoundException) {
73
             $exception = new NotFoundHttpException($exception->getMessage(), $exception);
73
             $exception = new NotFoundHttpException($exception->getMessage(), $exception);
74
         }
74
         }
75
 
75
 
76
-        // Authentication
76
+        // Authentication 401
77
         if ($exception instanceof AuthenticationException) {
77
         if ($exception instanceof AuthenticationException) {
78
             return $this->apiExceptionResponse($exception, Response::HTTP_UNAUTHORIZED, config('response-message.authenticate_failed'));
78
             return $this->apiExceptionResponse($exception, Response::HTTP_UNAUTHORIZED, config('response-message.authenticate_failed'));
79
         }
79
         }
88
             return $this->apiExceptionResponse($exception, $exception->getStatusCode(), $exception->getMessage());
88
             return $this->apiExceptionResponse($exception, $exception->getStatusCode(), $exception->getMessage());
89
         }
89
         }
90
 
90
 
91
-        // Query
91
+        // Query 500
92
         if ($exception instanceof QueryException) {
92
         if ($exception instanceof QueryException) {
93
             $this->apiExceptionResponse($exception, Response::HTTP_INTERNAL_SERVER_ERROR, config('response-message.sql_error'));
93
             $this->apiExceptionResponse($exception, Response::HTTP_INTERNAL_SERVER_ERROR, config('response-message.sql_error'));
94
         }
94
         }