sinew_exception library

SinewException types, handlers, processCall, CrashReporter and Localizer.

Classes

CrashReporter
Where the guards report bugs (unexpected and parse failures).
ExceptionHandler
One rule in a guard's handler list: "is this a timeout?" and "make a RequestTimeOutException for this call".
Localizer
How the app resolves a local message key in the current language.

Extensions

DisplayMessage on SinewException
Renders a SinewException for a page.

Functions

envelopeDataMissing(String module, String function, ExceptionLayer layer) → ExceptionHandler
The handler every list ends with: an envelope with no payload becomes a ParseException for this call.
processCall<T>(String module, String function, ExceptionLayer layer, List<ExceptionHandler> handlers, Future<T> block()) → Future<Result<T>>
The guard core every guard is built on, public so an app can guard calls Sinew doesn't know about.
processUseCase<T>(String module, String function, Future<T> body()) → Future<Result<T>>
The use-case guard: no handlers, so repository failures and domain exceptions pass through, and a bug becomes …-UC-…-GEN.

Exceptions / Errors

ApiErrorException
The backend reported a failure with a readable message: an envelope failure() or an error body. Always server text.
CancelException
A cancelled request. Never displayed and never reported: cancelling isn't a failure.
ConflictException
A 409.
ForbiddenException
A 403.
LocalStorageCorruptionException
Stored data that can't be read back: a failed decryption or bytes that don't decode.
NoInternetConnectionException
No connection, a DNS failure, or a refused or reset connection.
NotFoundException
A 404.
ParseException
A body that couldn't be parsed or mapped. Reported: it's a bug in the app or the backend.
PollingTimeOutException
Polling gave up while the backend was still processing.
RateLimitedException
A 429. Its local message names the wait when the backend sent Retry-After.
RequestTimeOutException
A connect, send or receive timeout, or the total deadline passed.
ServerException
Any 5xx except 503 and 504 (500, 501, 502, 505…): the backend's side.
ServiceUnavailableException
A 503 or 504: the backend is busy or a gateway timed out, so a retry may succeed.
StorageFullException
The device is out of space.
StorageReadException
Any other storage error, on a read.
StorageWriteException
Any other storage error, on a write.
UnauthorizedException
A 401 the auth layer couldn't recover from.
UndefinedErrorResponseException
Any other non-2xx status without a readable message.
UnexpectedException
Anything no handler recognised: a bug. Reported.
ValidationException
A 400 or 422 with field messages. The form message is the backend's when it sent one; field messages are shown beside their fields without a code.