summaryrefslogtreecommitdiff
path: root/spec/support/helpers/detailed_error_helpers.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/helpers/detailed_error_helpers.rb')
-rw-r--r--spec/support/helpers/detailed_error_helpers.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/support/helpers/detailed_error_helpers.rb b/spec/support/helpers/detailed_error_helpers.rb
new file mode 100644
index 00000000000..2da53a6bffd
--- /dev/null
+++ b/spec/support/helpers/detailed_error_helpers.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+require 'google/rpc/status_pb'
+require 'google/protobuf/well_known_types'
+
+module DetailedErrorHelpers
+ def new_detailed_error(error_code, error_message, details)
+ status_error = Google::Rpc::Status.new(
+ code: error_code,
+ message: error_message,
+ details: [Google::Protobuf::Any.pack(details)]
+ )
+
+ GRPC::BadStatus.new(
+ error_code,
+ error_message,
+ { "grpc-status-details-bin" => Google::Rpc::Status.encode(status_error) })
+ end
+end