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

import AWSSDKSwiftCore

/// Error enum for IoTJobsDataPlane
public enum IoTJobsDataPlaneErrorType: AWSErrorType {
    case invalidRequestException(message: String?)
    case resourceNotFoundException(message: String?)
    case throttlingException(message: String?)
    case serviceUnavailableException(message: String?)
    case certificateValidationException(message: String?)
    case invalidStateTransitionException(message: String?)
    case terminalStateException(message: String?)
}

extension IoTJobsDataPlaneErrorType {
    public init?(errorCode: String, message: String?){
        var errorCode = errorCode
        if let index = errorCode.index(of: "#") {
            errorCode = String(errorCode[errorCode.index(index, offsetBy: 1)...])
        }
        switch errorCode {
        case "InvalidRequestException":
            self = .invalidRequestException(message: message)
        case "ResourceNotFoundException":
            self = .resourceNotFoundException(message: message)
        case "ThrottlingException":
            self = .throttlingException(message: message)
        case "ServiceUnavailableException":
            self = .serviceUnavailableException(message: message)
        case "CertificateValidationException":
            self = .certificateValidationException(message: message)
        case "InvalidStateTransitionException":
            self = .invalidStateTransitionException(message: message)
        case "TerminalStateException":
            self = .terminalStateException(message: message)
        default:
            return nil
        }
    }
}