Getting sane errors out of sprocs
See original GitHub issueIs your feature request related to a problem? Please describe.
I just want a sensible way/guidance to get errors out of procs. Throwing Error
per the docs is fine and dandy, except now you’ve no practical way of switching on error codes or the likes from the client side. Throwing a JSON-formatted string and catching BadRequestException
/ DocumentClientException
seemed promising, except both those exceptions are (inexplicably) internal types with no way of getting the Error
object without reflection. Also, they get unwrapped into a CosmosException
which throws away the Error
property altogether and leaves you with little choice but to do string manipulation on its Message
property.
Describe the solution you’d like Make it practical to get errors out of sprocs and UDFs in such a way that the client can obtain information about what went wrong. Add relevant information to the docs.
Describe alternatives you’ve considered As best I can tell, all alternatives are hacks. Reflection, string parsing etc. Yuck.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top GitHub Comments
Thanks @mkolt - this is great.
Per my original request though, I don’t think this issue should be closed until this information has been added to the docs. I just tried googling “Cosmos DB SubStatusCode errorCode” and can’t find anything in the docs about this. Actually, one of the first results to come up is this user voice.
I agree. This is poor or forced design. Error codes within errors throws from sprocs cause always a BadRequestException without any data except a cosmosError added by force to suck Exception and the internal sub error codes. I think the container client should parse the error codes, not the user