question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting sane errors out of sprocs

See original GitHub issue

Is 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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
kentcbcommented, Feb 25, 2019

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.

0reactions
AlejandroBlancocommented, Aug 19, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Call a Stored Procedure which has errors, continue and get ...
ExecuteNonQuery() , which works, but it breaks on the first error. Is there any way to call a SP from C# without breaking...
Read more >
How To Return Error Message In Stored Procedure
Using the out parameter variable, we can get the error details outside the stored procedure. 1. 2. 3. 4. 5. 6. 7.
Read more >
Trying to trace error in Stored Procedure using XEvents
So, I am attempting to find out how to use XEvents to see the exact INSERT/UPDATE statement that the error is really occurring...
Read more >
ERROR_PROCEDURE (Transact-SQL) - SQL Server
This function returns the name of the stored procedure or trigger where an error occurs, if that error caused the CATCH block of...
Read more >
Trying to Connect to Store Procedure Getting an Error
I'm trying to connect to a stored procedure on one of our server-databases. I have been granted permissions to execute SP's in the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found