Return an error DTO

when i get an error in my applicaiton i return an httperror with an DTO.
The problem is on the client side i don’t have the LicenseErrorDto. I’m note sure what i’m doing wrong.

Please guide me

   public static Exception LicenseExceeded(Guid companyId,string itemType)
        LicenseErrorDto error = GetLicenseErrorDto(companyId, itemType);

        throw new HttpError(error, HttpStatusCode.UpgradeRequired, "LicenseExceeded", Resources.ErrorMessages.LicenseExceeded.Fmt(itemType));

Please read docs on Error Handling, you can return a HttpError containing a Response DTO with a populated ResponseStatus.

ServiceStack’s Error Responses return structured Error Responses where they’re converted into Exceptions on the client, e.g. in C# it wraps your Service Exception in a WebServiceException where you’ll be able to access your ResponseStatus from ex.ResponseStatus. This works similarly in other clients where a local Exception is thrown.

Hi, thx for your reply.
I have used Responsestatus to set ResponseErrors before but this time i want to add my own DTO object
with this structure instead of the standard ResponseStatus or ResponseError

  public class LicenseErrorDto
    public string Header { get; set; }
    public string Body { get; set; }
    public Uri ImageUrl { get; set; }
    public LicenseTypeQueryResponse SuggestedLicenseToUpgrade { get; set; }

All ServiceStack clients expects the same structured error response schema as populated in a ResponseStatus DTO, if you return your own error response DTO it wont be supported in the existing Service clients or client libraries which automatically bind field errors to UIs, etc.

With that said to return your own error DTO by returning the DTO as normal and setting the Response StatusCode in your Service implementation, e.g:

public object Any(MyRequest request)
    Response.StatusCode = (int) HttpStatusCode.UpgradeRequired;
    return new LicenseErrorDto { ... }