Module: Prototok::Errors

Included in:
Prototok
Defined in:
lib/prototok/errors.rb

Defined Under Namespace

Classes: CipherError, ConfigurationError, ExternalError, FormatError, TypeMismatch

Constant Summary collapse

MESSAGES =
{
  encoder: 'No such encoder declared',
  cipher: 'No such cipher declared',
  formatter: 'No such formatter declared',
  no_payload_proto_file: 'No payload .proto file path configured',
  type_expected: '%s expects %s value, got %s',
  external_command: 'have issues with system util "%s".
  Try to run "%s" by hand. Maybe you have to install it'
}.freeze

Instance Method Summary collapse

Instance Method Details

#err(error_class, message_name, *args, **keywords) ⇒ Object

Raises:

  • (error_class)


18
19
20
21
22
23
# File 'lib/prototok/errors.rb', line 18

def err(error_class, message_name, *args, **keywords)
  message = (Errors::MESSAGES[message_name] || "")
  message %= args unless args.empty?
  message %= keywords unless keywords.empty?
  raise(error_class, message)
end