Exception: ActiveSanction::Sync::Failed

Inherits:
StandardError
  • Object
show all
Extended by:
T::Sig
Includes:
Error
Defined in:
lib/active_sanction/sync.rb

Overview

Raised by Report#success!, for a caller that wants any failure fatal. Never raised by the run itself: by the time a failure is known, every other source has already been fetched and stored.

The one error in the hierarchy that is about a run rather than about one list, which is why it hangs off Error directly and carries the whole report rather than a single #source_id.

Instance Attribute Summary collapse

Attributes included from Error

#source_id, #status

Instance Method Summary collapse

Methods included from Error

#in_source, #to_h

Constructor Details

#initialize(report) ⇒ void

Parameters:



115
116
117
118
# File 'lib/active_sanction/sync.rb', line 115

def initialize(report)
  @report = T.let(report, Report)
  super(report.failure_message)
end

Instance Attribute Details

#report ⇒ Report (readonly)

Returns:



112
113
114
# File 'lib/active_sanction/sync.rb', line 112

def report
  @report
end

Instance Method Details

#retryable? ⇒ Boolean

True only when every source that failed failed retryably -- a run with one publisher timing out is worth re-running, and a run with a parse error in it is not going to come out differently in five minutes. A failure whose exception did not survive a round-trip through #to_h counts as not retryable, since nothing is known about it.

Returns:

  • (Boolean)


126
127
128
129
# File 'lib/active_sanction/sync.rb', line 126

def retryable?
  failures = report.failed.map(&:exception)
  retryable_or(failures.any? && failures.all? { |e| e.is_a?(ActiveSanction::Error) && e.retryable? })
end