You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var _ = API("app", func() {
Title("Payment API")
Description("Payment API for QR and IPG payments")
Server("app", func() {
Services("app")
})
})
var _ = Service("app", func() {
Description("Payment Service")
Files("/openapi.json", "gen/http/openapi3.json")
Method("createIPGOrder", func() {
Description("Create an order for IPG payment")
Security(APIKeyAuth)
Payload(CreateIPGPaymentOrderRequest)
Result(HTTPCommonResponse)
Error("bad_request", CommonErrorResponse, "Bad Request")
Error("internal_error", CommonErrorResponse, "Internal Server Error")
Error("unauthorized", CommonErrorResponse, "Operation failed due to unauthorized access")
Error("not_found", CommonErrorResponse, "Resources not found")
Error("conflicts", CommonErrorResponse, "Existing Order")
HTTP(func() {
POST("xxxxxx")
Header("xxxxxxxx")
Response(StatusCreated)
Response("bad_request", StatusBadRequest)
Response("not_found", StatusNotFound)
Response("internal_error", StatusInternalServerError)
Response("unauthorized", StatusUnauthorized)
Response("conflicts", StatusConflict)
})
})
}
and in my service implementation i implement it like this
return nil, &app.CommonErrorResponse{
Name: "internal_error",
Status: 1,
Message: "MerchantId is not parsed from auth middleware or not a string",
Timestamp: time.Now().Format(time.RFC3339),
}
But the response i get is still the default ServiceError by goa. Is this the expected behavior or is there something I do wrong ?
I don't see anything obviously wrong with the above (other than the name of the returned error would have to be "conflicts" to return 409 and not "internal_error" but I'm guessing that's just a copy/paste error :) ). Would you be able to provide a small complete repro? Also FYI Meta("struct:error:name") has been deprecated in favor of ErrorName (but it should still work).
In my design file I define this custom error response
And i use it in the service like this
and in my service implementation i implement it like this
But the response i get is still the default ServiceError by goa. Is this the expected behavior or is there something I do wrong ?
Response I get
What I expect
The text was updated successfully, but these errors were encountered: