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' }, billing: { retryable: false, description: 'App billing credit insufficient for the operation' }, internal: { retryable: false, description: 'Unexpected internal error' } }.freeze
Class Method Summary collapse
Class Method Details
.kind_for_exception(error) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mixin_bot/cli/errors.rb', line 31 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 InsufficientAppBillingError :billing when ResponseError, RequestError, HttpError, InsufficientBalanceError, UtxoInsufficientError, InsufficientPoolError :api_error else :internal end end |
.kind_for_message(message) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/mixin_bot/cli/errors.rb', line 49 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
21 22 23 24 25 26 27 28 29 |
# File 'lib/mixin_bot/cli/errors.rb', line 21 def schema_errors ERROR_KINDS.map do |kind, | { 'kind' => kind.to_s, 'retryable' => [:retryable], 'description' => [:description] } end end |