Module: Gritz::Errors
- Defined in:
- /home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/errors.rb,
tmp/docs-input/dynamic_api.rb
Overview
gRPC's canonical codes, without a dependency on the grpc gem.
Defined Under Namespace
Classes: Aborted, AlreadyExists, Cancelled, DataLoss, DeadlineExceeded, FailedPrecondition, Internal, InvalidArgument, NotFound, Ok, OutOfRange, PermissionDenied, ResourceExhausted, Unauthenticated, Unavailable, Unimplemented, Unknown
Constant Summary collapse
- CODES =
%i[ok cancelled unknown invalid_argument deadline_exceeded not_found already_exists permission_denied resource_exhausted failed_precondition aborted out_of_range unimplemented internal unavailable data_loss unauthenticated].freeze
Class Method Summary collapse
Class Method Details
.for_code(code) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File '/home/runner/work/gritz/gritz/sources/gritz-core/lib/gritz/errors.rb', line 37 def self.for_code(code) name = case code when Integer then CODES[code] if code >= 0 when String, Symbol then code.to_sym end raise ArgumentError, "unknown RPC status: #{code.inspect}" unless CODES.include?(name) const_get(name.to_s.split("_").map(&:capitalize).join, false) end |