Status codes

View Source

Every gRPC call ends with a status code. livery_grpc represents the 16 canonical codes as atoms; livery_grpc_status converts between the atom, the integer, and the wire value.

The codes

AtomCode
ok0
cancelled1
unknown2
invalid_argument3
deadline_exceeded4
not_found5
already_exists6
permission_denied7
resource_exhausted8
failed_precondition9
aborted10
out_of_range11
unimplemented12
internal13
unavailable14
data_loss15
unauthenticated16

Using them

Return a code atom from a handler:

{error, permission_denied}
{error, {permission_denied, <<"token expired">>}}

Convert when you need to:

3  = livery_grpc_status:code(invalid_argument),
invalid_argument = livery_grpc_status:name(3),
<<"5">> = livery_grpc_status:to_binary(not_found),
not_found = livery_grpc_status:from_binary(<<"5">>).

An unknown integer maps to unknown, so a peer using a code livery_grpc does not model still yields a usable value.

See also