// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/swift-aws/aws-sdk-swift/blob/master/CodeGenerator/Sources/CodeGenerator/main.swift. DO NOT EDIT.

import AWSSDKSwiftCore

/// Error enum for CloudWatch
public enum CloudWatchErrorType: AWSErrorType {
    case concurrentModificationException(message: String?)
    case dashboardInvalidInputError(message: String?)
    case internalServiceFault(message: String?)
    case invalidFormatFault(message: String?)
    case invalidNextToken(message: String?)
    case invalidParameterCombinationException(message: String?)
    case invalidParameterValueException(message: String?)
    case limitExceededException(message: String?)
    case limitExceededFault(message: String?)
    case missingRequiredParameterException(message: String?)
    case resourceNotFound(message: String?)
    case resourceNotFoundException(message: String?)
}

extension CloudWatchErrorType {
    public init?(errorCode: String, message: String?){
        var errorCode = errorCode
        if let index = errorCode.firstIndex(of: "#") {
            errorCode = String(errorCode[errorCode.index(index, offsetBy: 1)...])
        }
        switch errorCode {
        case "ConcurrentModificationException":
            self = .concurrentModificationException(message: message)
        case "InvalidParameterInput":
            self = .dashboardInvalidInputError(message: message)
        case "InternalServiceError":
            self = .internalServiceFault(message: message)
        case "InvalidFormat":
            self = .invalidFormatFault(message: message)
        case "InvalidNextToken":
            self = .invalidNextToken(message: message)
        case "InvalidParameterCombination":
            self = .invalidParameterCombinationException(message: message)
        case "InvalidParameterValue":
            self = .invalidParameterValueException(message: message)
        case "LimitExceededException":
            self = .limitExceededException(message: message)
        case "LimitExceeded":
            self = .limitExceededFault(message: message)
        case "MissingParameter":
            self = .missingRequiredParameterException(message: message)
        case "ResourceNotFound":
            self = .resourceNotFound(message: message)
        case "ResourceNotFoundException":
            self = .resourceNotFoundException(message: message)
        default:
            return nil
        }
    }
}

extension CloudWatchErrorType : CustomStringConvertible {
    public var description : String {
        switch self {
        case .concurrentModificationException(let message):
            return "ConcurrentModificationException: \(message ?? "")"
        case .dashboardInvalidInputError(let message):
            return "InvalidParameterInput: \(message ?? "")"
        case .internalServiceFault(let message):
            return "InternalServiceError: \(message ?? "")"
        case .invalidFormatFault(let message):
            return "InvalidFormat: \(message ?? "")"
        case .invalidNextToken(let message):
            return "InvalidNextToken: \(message ?? "")"
        case .invalidParameterCombinationException(let message):
            return "InvalidParameterCombination: \(message ?? "")"
        case .invalidParameterValueException(let message):
            return "InvalidParameterValue: \(message ?? "")"
        case .limitExceededException(let message):
            return "LimitExceededException: \(message ?? "")"
        case .limitExceededFault(let message):
            return "LimitExceeded: \(message ?? "")"
        case .missingRequiredParameterException(let message):
            return "MissingParameter: \(message ?? "")"
        case .resourceNotFound(let message):
            return "ResourceNotFound: \(message ?? "")"
        case .resourceNotFoundException(let message):
            return "ResourceNotFoundException: \(message ?? "")"
        }
    }
}
