Mithir
Mithir

Reputation: 2423

Returning an error without throwing an exception with servicestack

From what I know, exception throwing can be a little heavy. I can see that ServiceStack's Error handling suggests throwing an exception, which gets beautifully serialized to the client side.

1. How can I do the same without throwing the exception? - I see I can change the return type to object and return the HttpError instead of throwing, is this the only way?

2. Will performance improve (vs throwing)?

Upvotes: 1

Views: 107

Answers (1)

mythz
mythz

Reputation: 143319

Returning or throwing a HttpError has the same effect, e.g:

return new HttpError(HttpStatusCode.Conflict, "SomeErrorCode");

Upvotes: 2

Related Questions