Page MenuHomeDevCentral

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

Authored by dereckson on Sun, Aug 9, 22:41.
Tags
None
Referenced Files
F43897860: D4152.diff
Fri, Aug 14, 07:57
F43888314: D4152.id.diff
Fri, Aug 14, 06:36
F43883687: D4152.id10883.diff
Fri, Aug 14, 05:57
F43855936: D4152.id10884.diff
Fri, Aug 14, 02:37
F43818953: D4152.diff
Thu, Aug 13, 22:29
Unknown Object (File)
Thu, Aug 13, 07:25
Unknown Object (File)
Thu, Aug 13, 02:07
Unknown Object (File)
Wed, Aug 12, 07:16
Subscribers
None

Details

Summary

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.

Diff Detail

Repository
rLF Limiting Factor
Lint
Lint Not Applicable
Unit
Tests Not Applicable