scolby33 / OCSPdash

A dashboard for the status of the top certificate authorities' OCSP responders.
MIT License
1 stars 0 forks source link

Add error handling to the API blueprint. #40

Open scolby33 opened 6 years ago

scolby33 commented 6 years ago

Will close #25.

codecov[bot] commented 6 years ago

Codecov Report

Merging #40 into develop will increase coverage by 8.82%. The diff coverage is 24.27%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #40      +/-   ##
===========================================
+ Coverage     42.9%   51.73%   +8.82%     
===========================================
  Files           20       21       +1     
  Lines          825      893      +68     
  Branches        75       79       +4     
===========================================
+ Hits           354      462     +108     
+ Misses         461      418      -43     
- Partials        10       13       +3
Impacted Files Coverage Δ
src/ocspdash/models.py 77.14% <ø> (ø) :arrow_up:
src/ocspdash/web/app.py 86.66% <100%> (+86.66%) :arrow_up:
src/ocspdash/web/blueprints/api.py 29.52% <12.32%> (+29.52%) :arrow_up:
src/ocspdash/web/exceptions.py 43.75% <43.75%> (ø)
src/ocspdash/manager.py 63.08% <50%> (+0.75%) :arrow_up:
src/ocspdash/web/extension.py 93.33% <66.66%> (+93.33%) :arrow_up:
src/ocspdash/web/admin.py 43.75% <0%> (+43.75%) :arrow_up:
... and 5 more

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 4472751...fcfdcee. Read the comment docs.

scolby33 commented 6 years ago

I agree so many 400's is not the best, but none of the other error codes seem to fit better.

One thing I have seen is returning JSON errors like (for Pushover, for example):

{
  "user": "invalid",
  "errors": [
    "user identifier is invalid"
  ],
  "status": 0,
  "request": "5042853c-402d-4a18-abcb-168734a801de"
}

Despite them having a list of errors, I don't think I ever saw a response with more than one there.

cthoyt commented 6 years ago

You can return json and give it a non-200 error

scolby33 commented 6 years ago

Well, gonna try this now http://flask.pocoo.org/docs/1.0/patterns/apierrors/

cthoyt commented 6 years ago

yo whats going on with this PR

cthoyt commented 5 years ago

BUMP