Client unable to parse responseStatus when service throws exception

Hi,
I am using @servicestack/client 2.0.8 and unable to resolve a situation where a servicestack service is throwing an exception but the client is failing to serialize the responseStatus from the request body, I get the error message and I can’t get the error message sent from the server.

[TypeError: right operand of 'instanceof' is not an object]

I’ve follwed the code to here on in the sourcecode

For brevity I have hardcoded the service call

        public object Post(SiteSignOff request)
        {
            var response = new SiteSignOffResponse();

            // await Mediator.Send(new CommandSiteSignOff(request.DriverJobId, UserSession.AmazonId,
            //     request.JobSiteRequirement));

            throw new ArgumentException("Bad id");

            return response;
        }

I have checked the responseBody and it has a responseStatus

{
  "responseStatus": {
    "errorCode": "ArgumentException",
    "message": "Bad id",
    "stackTrace": null,
    "errors": [],
    "meta": null
  }
}

And this is a screenshot of the response headers

Not sure what I’m missing.

Thanks

Neither do I, what browser are you seeing this error in?

I’m calling the service from a React Native project, also if it helps I’m using the ServiceStack JsonApiClient

@mythz I think the issue is on this line

error instanceof (window as any).DOMException

DOMException is undefined is this because I’m using ReactNative?

Can you share the full stacktrace you are seeing? Also what platform is your application targeting when you hit this error?

Right, please specify you’re using React Native if you’re having issues on React Native in future.

I’ve added an additional guards in latest @servicestack/client v2.0.9 on npm.

@mythz I will do in the future and thanks for getting the fix out.

Btw are there any additional dev notes you can point me to in order to get the tests to run locally for the client repo I’ve been looking at?

No, there isn’t any.

1 Like