Module: WavefrontCli::ExceptionMixins
- Included in:
- WavefrontCliController
- Defined in:
- lib/wavefront-cli/exception_handler.rb
Overview
Handle fatal errors.
Instance Method Summary collapse
-
#exception_handler(exception) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity.
Instance Method Details
#exception_handler(exception) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/wavefront-cli/exception_handler.rb', line 14 def exception_handler(exception) case exception when WavefrontCli::Exception::UnhandledCommand abort 'Fatal error. Unsupported command. Please open a Github issue.' when WavefrontCli::Exception::InvalidInput abort "Invalid input. #{exception.}" when Interrupt abort "\nOperation aborted at user request." when WavefrontCli::Exception::ConfigFileNotFound abort "Configuration file #{exception}' not found." when WavefrontCli::Exception::CredentialError, Wavefront::Exception::CredentialError handle_missing_credentials(exception) when WavefrontCli::Exception::MandatoryValue abort 'A value must be supplied.' when Wavefront::Exception::NetworkTimeout abort 'Connection timed out.' when Wavefront::Exception::InvalidPermission abort "'#{exception}' is not a valid Wavefront permission." when Wavefront::Exception::InvalidTimestamp abort "'#{exception}' is not a parseable time." when Wavefront::Exception::InvalidUserGroupId abort "'#{exception}' is not a valid user group ID." when Wavefront::Exception::InvalidAccountId abort "'#{exception}' is not a valid system or user account ID." when Wavefront::Exception::InvalidAwsExternalId abort "'#{exception}' is not a valid AWS external ID." when Wavefront::Exception::InvalidRoleId abort "'#{exception}' is not a valid role ID." when Wavefront::Exception::InvalidApiTokenId abort "'#{exception}' is not a valid API token ID." when Wavefront::Exception::InvalidIngestionPolicyId abort "'#{exception}' is not a valid ingestion policy ID." when Wavefront::Exception::InvalidVersion abort "'#{exception}' is not a valid version." when WavefrontCli::Exception::InvalidValue abort "Invalid value for #{exception}." when WavefrontCli::Exception::ProfileExists abort "Profile '#{exception}' already exists." when WavefrontCli::Exception::ProfileNotFound abort "Profile '#{exception}' not found." when WavefrontCli::Exception::FileNotFound abort 'File not found.' when WavefrontCli::Exception::InsufficientData abort "Insufficient data. #{exception.}" when WavefrontCli::Exception::InvalidQuery abort "Invalid query. API message: '#{exception.}'." when WavefrontCli::Exception::SystemError abort "Host system error. #{exception.}" when WavefrontCli::Exception::UnparseableInput abort "Cannot parse input. #{exception.}" when WavefrontCli::Exception::UnparseableSearchPattern abort 'Searches require a key, a value, and a match operator.' when WavefrontCli::Exception::UnsupportedFileFormat abort 'Unsupported file format.' when WavefrontCli::Exception::UnsupportedOperation abort "Unsupported operation.\n#{exception.}" when WavefrontCli::Exception::UnsupportedOutput abort exception. when WavefrontCli::Exception::UnsupportedNoop abort 'Multiple API call operations cannot be performed as no-ops.' when WavefrontCli::Exception::UserGroupNotFound abort "Cannot find user group '#{exception.}'." when Wavefront::Exception::UnsupportedWriter abort "Unsupported writer '#{exception.}'." when WavefrontCli::Exception::UserError abort "User error: #{exception.}." when WavefrontCli::Exception::ImpossibleSearch abort 'Search on non-existent key. Please use a top-level field.' when Wavefront::Exception::InvalidSamplingValue abort 'Sampling rates must be between 0 and 0.05.' when Faraday::ConnectionFailed abort 'Error connecting to remote host.' else warn "general error: #{exception}" (exception) abort end end |