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
Unknown Object (File)
Sun, Aug 30, 02:05
Unknown Object (File)
Sat, Aug 29, 12:46
Unknown Object (File)
Wed, Aug 19, 05:33
Unknown Object (File)
Mon, Aug 17, 13:45
Unknown Object (File)
Sun, Aug 16, 12:48
Unknown Object (File)
Sun, Aug 16, 12:27
Unknown Object (File)
Sun, Aug 16, 07:12
Unknown Object (File)
Sun, Aug 16, 03:42
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 Passed
Unit
No Test Coverage
Branch
main
Build Status
Buildable 6786
Build 7074: arc lint + arc unit