Exception: Hook0::TransportError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/hook0/transport.rb

Overview

A request the API never answered, and what caused that.

The three causes are told apart because only one of them could end differently. A request that got no answer — a connection refused or reset, an attempt out of time, a body that stopped mid-way — says nothing about whether the API acted on it, which is exactly why a send carries an identifier the client chose itself, and why repeating it is safe and worth doing. An answer that crossed a ceiling this client set for itself draws the same answer the second time, and reading it again four times over costs the caller four times as much for the same failure. A URL nothing can be sent to was never sent at all, and a repetition builds the same unusable request, turning a misconfiguration into a message that accuses the network.

The names are the ones the shared conformance corpus gives them, so the verdict a client applies and the verdict that corpus writes down are the same words.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(detail, cause_name, retryable) ⇒ TransportError

Returns a new instance of TransportError.

Parameters:

  • detail (String)

    what went wrong, in the words a caller is given

  • cause_name (String)

    which of the corpus's causes this is

  • retryable (Boolean)

    whether repeating the request could end differently



30
31
32
33
34
# File 'lib/hook0/transport.rb', line 30

def initialize(detail, cause_name, retryable)
  super(detail)
  @cause_name = cause_name
  @retryable = retryable
end

Instance Attribute Details

#cause_nameString (readonly)

Returns which of the corpus's causes this is.

Returns:

  • (String)

    which of the corpus's causes this is



25
26
27
# File 'lib/hook0/transport.rb', line 25

def cause_name
  @cause_name
end

Class Method Details

.answer_above_a_bound(detail) ⇒ TransportError

The API answered, and what it answered crossed a ceiling this client set for itself.

Parameters:

  • detail (String)

Returns:



55
56
57
# File 'lib/hook0/transport.rb', line 55

def self.answer_above_a_bound(detail)
  new(detail, "answer_above_a_bound", false)
end

.no_answer(detail) ⇒ TransportError

The API was reached for and answered nothing this client could read to its end.

Parameters:

  • detail (String)

Returns:



47
48
49
# File 'lib/hook0/transport.rb', line 47

def self.no_answer(detail)
  new(detail, "no_answer", true)
end

.unusable_api_url(detail) ⇒ TransportError

There is nowhere to send the request, so nothing was sent.

Parameters:

  • detail (String)

Returns:



63
64
65
# File 'lib/hook0/transport.rb', line 63

def self.unusable_api_url(detail)
  new(detail, "unusable_api_url", false)
end

Instance Method Details

#retryable?Boolean

Whether repeating the request that met this could end differently.

Returns:

  • (Boolean)


39
40
41
# File 'lib/hook0/transport.rb', line 39

def retryable?
  @retryable
end