cloudendpoints / endpoints-java

A Java framework for building RESTful APIs on Google App Engine
Apache License 2.0
32 stars 35 forks source link

Add extra fields in ServiceException #182

Open llbrt opened 5 years ago

llbrt commented 5 years ago

The goal of these changes is to be able to add some extra fields in ServiceException, to give more details about the error. These fields may be documented by the service and used on the client side (diagnosis, help, ...).

For example, the field 'extendedHelp' in this reply

{
 "code" : 403,
 "errors" :
  [ {
    "domain" : "usageLimits",
    "message" : "User Rate Limit Exceeded. Rate of requests for user exceed configured project quota. You may consider re-evaluating expected per-user traffic to the API and adjust project quota limits accordingly. You may monitor aggregate quota usage and adjust limits in the API Console: https://console.developers.google.com/apis/api/drive.googleapis.com/quotas?project=xyz",
    "reason" : "userRateLimitExceeded",
    "extendedHelp" : "https://console.developers.google.com/apis/api/drive.googleapis.com/quotas?project=xyz"
  } ],
  "message" : "User Rate Limit Exceeded. Rate of requests for user exceed configured project quota. You may consider re-evaluating expected per-user traffic to the API and adjust project quota limits accordingly. You may monitor aggregate quota usage and adjust limits in the API Console: https://console.developers.google.com/apis/api/drive.googleapis.com/quotas?project=xyz"
}
codecov-io commented 5 years ago

Codecov Report

Merging #182 into master will increase coverage by 0.17%. The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #182      +/-   ##
============================================
+ Coverage     80.06%   80.24%   +0.17%     
- Complexity     1715     1721       +6     
============================================
  Files           159      159              
  Lines          5718     5734      +16     
  Branches        754      757       +3     
============================================
+ Hits           4578     4601      +23     
+ Misses          856      849       -7     
  Partials        284      284
Impacted Files Coverage Δ Complexity Δ
.../server/spi/response/RestResponseResultWriter.java 100% <100%> (ø) 6 <0> (+1) :arrow_up:
...va/com/google/api/server/spi/ServiceException.java 80.35% <100%> (+17.56%) 16 <8> (+4) :arrow_up:
...gle/api/server/spi/response/ConflictException.java 14.28% <0%> (+14.28%) 1% <0%> (+1%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 39b7374...73a2b75. Read the comment docs.