HomeDevCentral

Allow to easily throw error response in ApiJsonResponse<T> methdods

Description

Allow to easily throw error response in ApiJsonResponse<T> methdods

While StatusCode can already be parsed as a response,
it's not always easy to propagate the correct Ok() signature
in a method that only returns errors.

Throw the error variant is trivial, but verbose so an helper method
error_response(status_code, error_message) can be helpful to keep
code easy to read and maintain.

Expected use:

if ... {
    return error_response(StatusCode::..., "...");
}

Test Plan: Tested with Alkane HTTP API server code.

Differential Revision: https://devcentral.nasqueron.org/D4152

Details

Provenance
derecksonAuthored on Sun, Aug 9, 22:36
derecksonPushed on Sun, Aug 9, 22:42
Differential Revision
D4152: Allow to easily throw error response in ApiJsonResponse<T> methdods
Parents
rLF1ce13f823520: Support features required by Docker Registry API
Branches
Unknown
Tags
Unknown