// 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 Lightsail
public enum LightsailErrorType: AWSErrorType {
    case accessDeniedException(message: String?)
    case accountSetupInProgressException(message: String?)
    case invalidInputException(message: String?)
    case notFoundException(message: String?)
    case operationFailureException(message: String?)
    case serviceException(message: String?)
    case unauthenticatedException(message: String?)
}

extension LightsailErrorType {
    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 "AccessDeniedException":
            self = .accessDeniedException(message: message)
        case "AccountSetupInProgressException":
            self = .accountSetupInProgressException(message: message)
        case "InvalidInputException":
            self = .invalidInputException(message: message)
        case "NotFoundException":
            self = .notFoundException(message: message)
        case "OperationFailureException":
            self = .operationFailureException(message: message)
        case "ServiceException":
            self = .serviceException(message: message)
        case "UnauthenticatedException":
            self = .unauthenticatedException(message: message)
        default:
            return nil
        }
    }
}

extension LightsailErrorType : CustomStringConvertible {
    public var description : String {
        switch self {
        case .accessDeniedException(let message):
            return "AccessDeniedException: \(message ?? "")"
        case .accountSetupInProgressException(let message):
            return "AccountSetupInProgressException: \(message ?? "")"
        case .invalidInputException(let message):
            return "InvalidInputException: \(message ?? "")"
        case .notFoundException(let message):
            return "NotFoundException: \(message ?? "")"
        case .operationFailureException(let message):
            return "OperationFailureException: \(message ?? "")"
        case .serviceException(let message):
            return "ServiceException: \(message ?? "")"
        case .unauthenticatedException(let message):
            return "UnauthenticatedException: \(message ?? "")"
        }
    }
}
