File: service_failure_error.rb

package info (click to toggle)
ruby-circuitbox 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 140 kB
  • sloc: ruby: 533; makefile: 4
file content (20 lines) | stat: -rw-r--r-- 533 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

class Circuitbox
  class ServiceFailureError < Circuitbox::Error
    attr_reader :service, :original

    def initialize(service, exception)
      super()
      @service = service
      @original = exception
      # We copy over the original exceptions backtrace if there is one
      backtrace = exception.backtrace
      set_backtrace(backtrace) unless backtrace.empty?
    end

    def to_s
      "#{self.class}: Service #{service.inspect} was unavailable (original: #{original})"
    end
  end
end