Comments (7)
How I see function: wrap_function_by_validator(self, function, validator)
intercepts ValidationError
exception itself and print message.
So ... there is no way to detect validation error on application level, right?
from panini.
I just did minimal changes in pull request - #225 .
It's very simple soluton. Maybe it doesn't work for all cases. But it solves my problem with validation quite complicated messages come thru NATS and maybe helps you.
from panini.
Hello @kirill-ratkin
Indeed, catching a validator exception looks like a useful feature.
I'll check your PR soon
from panini.
@kirill-ratkin just checked PR #225
The thing is such implementation breaks all listener functions that donβt have an argument validation_report
.
I would consider adding validation_error_cb
as an argument for the listener decorator. For example:
async def custom_validation_error_cb(msg):
# custom msg handling
log.error(f"something wrong")
@app.listen("some.subject", validator=SomeValidator, validation_error_cb=custom_validation_error_cb)
async def foo(msg):
# msg handling if everything allright
log.info(f"got message {msg.data}")
What do you think? Would it be convenient for your case?
from panini.
Hi.
Yes. Good idea to add decorator parameter. It's better than mine solution.
What do you think to do with wrapped function call in case of validation error happened?
For my perpective wrapped functoin should not be called in this case and custom_validation_error_cb should be responsible for error handling. In my case I'll inform sender in reply about validation error.
Good idea!
from panini.
We will think about a wrapped function.
I can't guarantee but i think we will release the new version by the end of next week, the new version will include the validation error callback feature.
from panini.
#227 Update in new panini release - v0.7.1
from panini.
Related Issues (20)
- Add arg "start_in" for a task and an interval task HOT 1
- If adding a middleware in tests (ErrorMiddleware for ex.) - diff datatypes tests failing HOT 1
- ValueError: Expected object or value - ujson does not support NaN
- Type for 'async def subscribe_new_subject()' throw the warning HOT 1
- DebugMiddleware feature
- README.md for utils not correct HOT 1
- Middlewares do not allow to use sync functions HOT 1
- Add possibility not to use asyncio.iscoroutinefunction in middlewares, but still support sync def HOT 1
- If nats doen't answer - the panini becomes idle HOT 1
- Async Event Loop
- Exception DataTypeError happens but not catch HOT 2
- Custom Logger without files on a file system HOT 2
- DataTypeError raised when listener's return type is not JSON HOT 6
- TestClient.request() method does not have a data_type argument like the real client HOT 3
- Website returning 502 Bad Gateway HOT 1
- RuntimeError with aiohttp HOT 2
- listener app never receives request respone HOT 8
- AttributeError: 'NATSClient' object has no attribute '_js' HOT 1
- Move to nats-py 2.6.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from panini.