Skip to content

make internal Showcase errors be reported as proper gRPC errors with status and detais #1575

@vchudnov-g

Description

@vchudnov-g

As a result of #1573 , we'll be able to report errors in a more standard format. It would be elegant to update the reporting of internal Showcase errors to be in this more standard format.

To do this just on the REST side, it seems we would need to update goviewcreator.go to read something like this:

	file.P("func (backend *RESTBackend) ReportGRPCError(w http.ResponseWriter, err error) {")
	file.P("  st, ok := status.FromError(err)")
	file.P("  if !ok {")
	file.P(`    backend.Error(w, http.StatusInternalServerError, "** server error in ReportGRPCError: %%s\n---Error: %%+v\nStatus: %%+v\n", err.Error(), err, st)`)
	file.P(`    resttools.ErrorResponse(w, resttools.NoCodeHTTP, codes.Internal, "non-gRPC error", errdetails.ErrorInfo{Reason: err.Error(), Domain: "showcase server"})`)
	file.P("    return")
	file.P("  }")

(The line right before the return statement is the new one.)

However, we should also report these more stamdard errors over gRPC transport.

Moreover this has implications for existing Showcase unit tests and possibly for generator repositories which may depend on Showcase, so we should proceed with care.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions