Exception: Servus::Schema::UnknownKeyError

Inherits:
Error
  • Object
show all
Defined in:
lib/servus/schema/errors.rb

Overview

Raised when a $ref names a fragment key that is not registered.

This is the error the whole registry design exists to produce. A lookup that returned nil instead would let a service that appears to declare a contract run with no validation at all, indefinitely and silently.

Class Method Summary collapse

Class Method Details

.for(key, available:) ⇒ UnknownKeyError

Builds the error for a missed lookup, suggesting the nearest key.

Parameters:

  • key (String)

    the key that was not found

  • available (Array<String>)

    currently registered keys

Returns:



29
30
31
32
33
# File 'lib/servus/schema/errors.rb', line 29

def self.for(key, available:)
  return new(nothing_registered(key)) if available.empty?

  new("unknown schema key #{key.inspect}.#{suggestion(key, available)}")
end