Return the exception message as readable

Hi,

when a exception is thrown the service doesnt return it as a readable message to the client.
How can i do that?

Now i only get the HTTPErrorCode

And the response

Thx!

If this is in a filter? You’ll need to write to the Response directly (i.e. you can’t throw Exceptions as you’d do in Services), e.g:

res.StatusCode = (int)HttpStatusCode.Unauthorized;
res.EndRequest();

I did by doing this way. Correct?

Also i should’nt throw exceptions from my services?
Today i just throw an HttpError Exception

ie:

HttpError(HttpStatusCode.MethodNotAllowed, "Invalid license for company {0}".Fmt(companyId));

I guess I want to return an error response somehow instead

Yep that works.

You can throw Exceptions in your Service, that’s where it’s supported.

Very nice! All is working now! Thx!

1 Like