Option to throw error on extra arguments
See original GitHub issueWhen a request has more arguments than are specified in the parser it silently ignores them. I see a related discussion in #28.
Personally I don’t think silently ignoring is the correct thing to do, but changing the default behavior would be backwards incompatible. How about parse
takes a strict
option that throws an error in cases like this?
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Raise custom Exception with arguments - Stack Overflow
In case A, raise will call FooError.new('argh') , but your code expects an optional foo , not a message. This is bad. What...
Read more >Should I raise an exception/error when an optional argument ...
If an argument is mandatory, then you should raise an exception when it's not passed. However, if it's optional, then you should either...
Read more >TypeError: More arguments needed - JavaScript | MDN
The JavaScript exception "more arguments needed" occurs when there is an error with how a function is called. More arguments need to be ......
Read more >How to pass argument to an Exception in Python?
Using arguments for Exceptions in Python is useful for the following reasons: It can be used to gain additional information about the error ......
Read more >Best Practices for exceptions - .NET - Microsoft Learn
All exceptions derive from the Exception class. More derived exceptions aren't handled by a catch clause that's preceded by a catch clause for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sloria I sketched something from your pointers. It’s possibly close to what @ParthGandhi has been doing:
The implementation is bound to Flask now, and I do see the problem of making it cross-framework compatible. I only tested JSON location yet, so not sure if the others really work.
Also, this “no extras” feature is probably only wanted for JSON payloads, forms, files and maybe query parameters. It doesn’t really make sense for cookies and headers, imo.
In any case, I would expect support for this to exist in the library out of the box. Do you see any reasonable possibilities to maybe generalize the implementation (like adding more
parse_
methods for returning the collections or missing keys)?@ParthGandhi I would be curious to see your solution as well. It seems the flexibility in supporting multiple/varying locations per argument / set of arguments makes this one problematic…