anz-bank / sysl-go

Communication library used by SYSL-generated code written in Go.
Apache License 2.0
10 stars 14 forks source link

Is there a way to retrieve the error messages from downstreams? #159

Closed uynap closed 4 years ago

uynap commented 4 years ago

For example, UI -> BFF -> OtherAPI, when OtherAPI response:

< HTTP/1.1 500 Server Error
{
  "message" : [ {
    "text" : "Error while making call to ABC.",
    "type" : "error"
  } ]
}

At the moment, the BFF will response UI:

< HTTP/1.1 503 Server Error

without any details.

I know the raw message from the OtherAPI can be logged in sysl-go, but it’s hard to access the OtherAPI's customised error messages in BFF's handler functions. There are some use cases that the UI needs to present different things base on the error message received from the OtherAPI.

tiagralee commented 4 years ago

Linked Issue https://github.com/anz-bank/sysl-go/issues/105

andrewemeryanz commented 4 years ago

Implemented in https://github.com/anz-bank/sysl-go/pull/188. Pattern of use:

ctx = common.ProvisionRestResult(ctx)  // provision for the result in the context
response, err := client.PostRestFooBarWithArg(ctx, &request)
result := common.GetRestResult(ctx)  // retrieve the result from the context