Jaymon / endpoints

Lightweight REST api backend framework that automatically maps urls to python modules and classes
MIT License
29 stars 10 forks source link

have @param take an error message #109

Open Jaymon opened 4 years ago

Jaymon commented 4 years ago

so if you pass in @param("<NAME>", errmsg=...) it would use that errmsg as the error string if param fails in some way, this would allow us to fine tune client facing error messages

Jaymon commented 8 months ago

This could be done in call.Param's handle method. Basically do a try/except and then check if there is an errmsg flag, if there is then raise a new ValueError with the error message.

You could also allow minor templating with {value} or something like that and then it will always call format on the error message with certain predefined values (assuming format doesn't fail if it has keywords that aren't in the string)