Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@anovis
Copy link
Collaborator

@anovis anovis commented Oct 18, 2023

Use the errorhandler decorator to handle errors based on its exception class. By default GobletRouteNotFoundError is handled by returning a 404 response code.

   @app.errorhandler("GobletRouteNotFoundError")
    def handle_missing_route(error):
        return Response("Custom Error", status_code=404)

    @app.errorhandler("ValueError")
    def return_error_string(error):
        return Response(str(error), status_code=200)

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (cedebc4) 89.63% compared to head (db4aced) 89.72%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #445      +/-   ##
==========================================
+ Coverage   89.63%   89.72%   +0.08%     
==========================================
  Files          62       62              
  Lines        5634     5673      +39     
==========================================
+ Hits         5050     5090      +40     
+ Misses        584      583       -1     
Files Coverage Δ
goblet/decorators.py 90.20% <100.00%> (+0.35%) ⬆️
goblet/errors.py 100.00% <100.00%> (ø)
goblet/handlers/routes.py 93.81% <100.00%> (+0.36%) ⬆️
goblet/response.py 94.44% <100.00%> (+0.69%) ⬆️
goblet/tests/test_app.py 92.34% <100.00%> (+1.04%) ⬆️
goblet/resource_manager.py 77.46% <90.90%> (+0.76%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anovis anovis merged commit b248c87 into main Oct 18, 2023
@anovis anovis deleted the errorhandling branch October 18, 2023 14:44
quajones pushed a commit to quajones/goblet that referenced this pull request Oct 19, 2023
Use the `errorhandler` decorator to handle errors based on its exception
class. By default `GobletRouteNotFoundError` is handled by returning a
404 response code.

```
   @app.errorhandler("GobletRouteNotFoundError")
    def handle_missing_route(error):
        return Response("Custom Error", status_code=404)

    @app.errorhandler("ValueError")
    def return_error_string(error):
        return Response(str(error), status_code=200)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants