Exception: Aspera::Cli::BadIdentifier

Inherits:
Error
  • Object
show all
Defined in:
lib/aspera/cli/error.rb

Overview

Raised when a lookup for a specific entity fails to return exactly one result.

Provides a formatted message indicating whether the entity was missing or if multiple matches were found (ambiguity).

Instance Method Summary collapse

Constructor Details

#initialize(res_type, res_id, field: 'identifier', count: 0) ⇒ BadIdentifier

Returns a new instance of BadIdentifier.

Parameters:

  • res_type (String)

    The type of entity being looked up (e.g., ‘user’).

  • res_id (String)

    The value of the identifier that failed.

  • field (String) (defaults to: 'identifier')

    The name of the field used for lookup (defaults to ‘identifier’).

  • count (Integer) (defaults to: 0)

    The number of matches found (0 for not found, >1 for ambiguous).



21
22
23
24
# File 'lib/aspera/cli/error.rb', line 21

def initialize(res_type, res_id, field: 'identifier', count: 0)
  msg = count.eql?(0) ? 'not found' : "found #{count}"
  super("#{res_type} with #{field}=#{res_id}: #{msg}")
end