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
{{ message }}
Repository navigation
RPC layer should allow for returning error bodies #316
Right now RPCs just return empty bodies if there is any error. This means that if, say, the RA returns an UnauthorizedError, the WFE can't turn that into a 401 response code, nor provide a useful error message to the client.
One possible implementation: Instead of sending a JSON object representing their return type, RPC replies could send a JSON object that contains a field: returnValues, whose value is a JSON array of values returned from the implementing function. We could additionally define custom MarshalJSON and UnmarshalJSON methods for error that would turn errors into {value: "Some error", type: "UnauthorizedError"}.
When receiving a JSONified error, if the type was equal to string, we'd instantiate the correct type of error and fill it with the .Value(). For error types that are not equal to string, we'd just instantiate a generic error with the right value string.
Activity
jcjones commentedon Jun 6, 2015
Marking help-wanted; I think this would be a great intro to the RPC system for a new contributor.
jsha commentedon Jun 8, 2015
One possible implementation: Instead of sending a JSON object representing their return type, RPC replies could send a JSON object that contains a field:
returnValues, whose value is a JSON array of values returned from the implementing function. We could additionally define customMarshalJSONandUnmarshalJSONmethods forerrorthat would turn errors into{value: "Some error", type: "UnauthorizedError"}.When receiving a JSONified error, if the type was equal to
string, we'd instantiate the correct type of error and fill it with the.Value(). For error types that are not equal tostring, we'd just instantiate a generic error with the right value string.