Module: MixinBot::CLIErrors
- Defined in:
- lib/mixin_bot/cli/errors.rb
Overview
Maps exceptions and messages to clispec error kinds for structured CLI output.
Constant Summary collapse
- ERROR_KINDS =
{ invalid_args: { retryable: false, description: 'Invalid or missing arguments' }, auth: { retryable: false, description: 'Authentication or authorization failed' }, not_found: { retryable: false, description: 'Requested resource was not found' }, api_error: { retryable: false, description: 'Mixin API returned an error' }, unsupported: { retryable: false, description: 'Operation is not supported in this context' }, conflict: { retryable: false, description: 'Resource exists with incompatible configuration' }, internal: { retryable: false, description: 'Unexpected internal error' } }.freeze
Class Method Summary collapse
Class Method Details
.kind_for_exception(error) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mixin_bot/cli/errors.rb', line 30 def kind_for_exception(error) case error when MixinBot::ArgumentError, ::ArgumentError :invalid_args when UnauthorizedError, ForbiddenError, PinError, ConfigurationNotValidError :auth when NotFoundError, UserNotFoundError :not_found when ResponseError, RequestError, HttpError, InsufficientBalanceError, UtxoInsufficientError, InsufficientPoolError :api_error else :internal end end |
.kind_for_message(message) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/mixin_bot/cli/errors.rb', line 46 def () msg = .to_s.downcase return :auth if msg.include?('unauthorized') || msg.include?('authentication') return :not_found if msg.include?('not found') || msg.include?('404') return :unsupported if msg.include?('unsupported') || msg.include?('not supported') return :invalid_args if msg.include?('invalid') || msg.include?('unknown') :internal end |
.schema_errors ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/mixin_bot/cli/errors.rb', line 20 def schema_errors ERROR_KINDS.map do |kind, | { 'kind' => kind.to_s, 'retryable' => [:retryable], 'description' => [:description] } end end |