yuvalherziger / aiohttp-catcher Goto Github PK
View Code? Open in Web Editor NEWA centralized error handler for aiohttp servers
License: MIT License
A centralized error handler for aiohttp servers
License: MIT License
aiohttp throws exceptions for errors that correspond to standard HTTP errors. It would be nice to have a feature that initializes a catcher with pre-canned scenarios.
Right now, the Callables and Awaitables feature invokes those functions with a single argument, which is the exception thrown from aiohttp handlers. The goal of this feature is to add a second, optional positional argument for the aiohttp request object. This will add an additional level of flexibility for callables-as-error-responses.
Some API architectures dictate more complex error handling mechanisms. One example is GraphQL, where the following might be a legitimate response:
{
"errors": [
{
"message": "Name for character with ID 1002 could not be fetched.",
"locations": [ { "line": 6, "column": 7 } ],
"path": [ "hero", "heroFriends", 1, "name" ]
}
],
"data": {
"hero": {
"name": "R2-D2",
"heroFriends": [
{
"id": "1000",
"name": "Luke Skywalker"
},
{
"id": "1002",
"name": null
},
{
"id": "1003",
"name": "Leia Organa"
}
]
}
}
}
Notice that since part of the request (=GraphQL query) failed, the API would return errors alongside successfully-fetched data.
I'm still not 100% certain on how to tackle this, but it definitely warrants some thorough thinking.
The main challenge about partial error responses is that from a pure HTTP perspective, they're not errors and should therefore not be handled with exceptions. For this reason, I'm not convinced there's anything to do here, to begin with, but I'm keeping this issue open for future reference.
Right now, aiohttp-catcher only supports adding its middleware to aiohttp apps. The intention of this issue is to track the development of a feature that supports loading the app via a catcher method.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.