Page MenuHomeDevCentral

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

Authored by dereckson on Aug 9 2026, 22:41.
Tags
None
Referenced Files
F57770467: D4152.id10884.diff
Sun, Nov 22, 15:51
Unknown Object (File)
Sat, Nov 21, 10:09
Unknown Object (File)
Sat, Nov 21, 10:09
Unknown Object (File)
Wed, Nov 18, 18:08
Unknown Object (File)
Mon, Nov 16, 15:06
Unknown Object (File)
Sun, Nov 15, 14:03
Unknown Object (File)
Sat, Nov 14, 12:46
Unknown Object (File)
Sat, Nov 14, 00:20
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