From e94cf13b35db4a21aca5d1a21623a80404b0deba Mon Sep 17 00:00:00 2001 From: Tomas Abrahamsson Date: Thu, 12 May 2022 08:29:24 +0200 Subject: [PATCH] Align the gpc_error types more with the code Add a type to specify what error values that the server side can handle from rpc method callback functions, since this is slightly different from the errors that can be returned on the client side. --- src/grpcbox_stream.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/grpcbox_stream.erl b/src/grpcbox_stream.erl index d523f4d..fb941c0 100644 --- a/src/grpcbox_stream.erl +++ b/src/grpcbox_stream.erl @@ -31,6 +31,7 @@ grpc_status_message/0, grpc_error/0, grpc_error_response/0, + grpc_callback_error/0, grpc_error_data/0, grpc_extended_error_response/0]). @@ -61,15 +62,19 @@ -type t() :: #state{}. --type grpc_status_message() :: unicode:chardata(). +-type grpc_status_message() :: unicode:unicode_binary(). -type grpc_status() :: 0..16. -type http_status() :: integer(). --type grpc_error() :: {grpc_status(), grpc_status_message()}. +-type grpc_error() :: {binary(), % containing a grpc_status() value as text + grpc_status_message()}. -type grpc_error_response() :: {error, grpc_error(), #{headers => map(), trailers => #{}}} | {http_error, {http_status(), unicode:chardata()}, #{headers => map(), trailers => #{}}} | {error, term()}. +-type grpc_callback_error() :: {error, grpc_error(), #{headers => map(), + trailers => #{}}}. + -type grpc_error_data() :: #{ status := grpc_status(), message := grpc_status_message(),