1

I am using Dapr in a .Net microservices environment to communicate between different services. I have run into a situation where the called service is throwing an exception (could be for any reason) but the calling service only sees it returned as a Dapr InvocationException which seems to hide the original exception.

enter image description here

I can get the request body by calling Response.Content.ReadAsStringAsync which does return the original exception message, but also the entire stack trace and headers. enter image description here Is there any way to get the original exception object (ie. InvalidOperationException, ArgumentException etc) after catching the InvocationException?

2
  • also the entire stack trace and headers. that is the actual exception, and a lot more useful than just the message. Especially in this cases which clearly tells you the details are in the inner exception Commented Aug 25, 2023 at 13:13
  • In fact, if you only post the message in an SO question people will tell you to post the full text instead, because that shows not only any inner exceptions but which calls were made that led to that exception and can help you find which application method resulted in an error deep down your services or .NET stack Commented Aug 25, 2023 at 13:15

2 Answers 2

0

The documentation doesn't state anything, so I don't know if this is supported. For me, what you say, it's not working using the Dapr .NET SDK. The Response.Content is always empty.

I tried using the InnerException of the InvocationException. But it seems that it is an HttRequestException and it doesn't contain any information about the original Exception thrown in the target service.

Sign up to request clarification or add additional context in comments.

2 Comments

No API returns internal exceptions. That's a basic security rule
Thanks @PanagiotisKanavos. So that means, for this case, the way to go in order to get the inner exception is to go with a plain HTTP call instead of utilizing the Dapr .NET API, correct?
0

Try to put the following to metadata:

errorIfNot2XX = false

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.