Method: Gruf::Error#attach_to_call
- Defined in:
- lib/gruf/error.rb
#attach_to_call(active_call) ⇒ Error
Update the trailing metadata on the given gRPC call, including the error payload if configured to do so.
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/gruf/error.rb', line 151 def attach_to_call(active_call) [Gruf..to_sym] = serialize if Gruf. return self if .empty? || !active_call || !active_call.respond_to?(:output_metadata) # Check if we've overflown the maximum size of output metadata. If so, # log a warning and replace the metadata with something smaller to avoid # resource exhausted errors. if .inspect.size > MAX_METADATA_SIZE code = METADATA_SIZE_EXCEEDED_CODE msg = METADATA_SIZE_EXCEEDED_MSG logger.warn "#{code}: #{msg} Original error: #{to_h.inspect}" err = Gruf::Error.new(code: :internal, app_code: code, message: msg) return err.attach_to_call(active_call) end active_call..update() self end |