Class: WebFunction::DocumentedError

Inherits:
Object
  • Object
show all
Defined in:
lib/web_function/documented_error.rb

Overview

# DocumentedError

Represents an error definition as described in a Web Function package.

An error definition documents the possible errors that an endpoint might return, including a machine-readable error code and a human-readable description.

See the [error definition documentation] on the Web Function website for more details, including recognized keys and usage recommendations.

[0]: webfunction.org/package#error-definition

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ DocumentedError

Returns a new instance of DocumentedError.



15
16
17
# File 'lib/web_function/documented_error.rb', line 15

def initialize(error)
  @error = error
end

Instance Method Details

#codeString

## Code

The code of the error.

Returns:

  • (String)


25
26
27
# File 'lib/web_function/documented_error.rb', line 25

def code
  @error["code"]
end

#docsString

## Docs

The documentation of the error.

Returns:

  • (String)


35
36
37
# File 'lib/web_function/documented_error.rb', line 35

def docs
  @error["docs"].to_s
end