Exception: Insika::WorkflowSchemaError

Inherits:
ValidationError show all
Defined in:
lib/insika/errors.rb

Overview

Workflow I/O contract violation. A workflow may declare an input_schema / output_schema; a value that does not conform is rejected. INPUT is validated SYNCHRONOUSLY (TriggerWorkflow) so it is a ValidationError -> HTTP 422, no run created. OUTPUT is validated inside the fiber after the workflow returns -> task :failed at the :workflow_schema stage. errors is the per-field detail (dry-schema-compatible #errors.to_h); phase is :input|:output.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, phase: nil, errors: {}) ⇒ WorkflowSchemaError

Returns a new instance of WorkflowSchemaError.



169
170
171
172
173
174
175
# File 'lib/insika/errors.rb', line 169

def initialize(message = nil, phase: nil, errors: {})
  @phase = phase
  @errors = errors || {}
  detail = @errors.map { |field, msgs| "#{field}: #{Array(msgs).join(', ')}" }.join("; ")
  base = message || "workflow #{phase} failed schema validation"
  super(detail.empty? ? base : "#{base} (#{detail})")
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



167
168
169
# File 'lib/insika/errors.rb', line 167

def errors
  @errors
end

#phaseObject (readonly)

Returns the value of attribute phase.



167
168
169
# File 'lib/insika/errors.rb', line 167

def phase
  @phase
end