I have a Lambda application integrated with API Gateway, and I want to return this response body in the case of 409 error (conflict exception)
{
"message": "some error message",
"someObject": {
"propert1": "val1"
}
}
But according to this documentation https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Response.html#error-property, the error object doesn't expose deserialized data from service, except for message. Hence, in my JavaScript application, I only have an access to message property: "some error message", but I need to access someObject. How can I solve this? Do I need to serialize the object and bind it to message property?
I am using REST API and in Lambda we use javax.ws.rs.core.Response to return a response
data class Error(val message: String, val someObject: SomeDataClass)
...
val error = Error('message', someObject)
return Response.status(code).entity(error).build()