//===----------------------------------------------------------------------===//
//
// This source file is part of the AWSSDKSwift open source project
//
// Copyright (c) 2017-2020 the AWSSDKSwift project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of AWSSDKSwift project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// 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 ECR
public enum ECRErrorType: AWSErrorType {
    case emptyUploadException(message: String?)
    case imageAlreadyExistsException(message: String?)
    case imageDigestDoesNotMatchException(message: String?)
    case imageNotFoundException(message: String?)
    case imageTagAlreadyExistsException(message: String?)
    case invalidLayerException(message: String?)
    case invalidLayerPartException(message: String?)
    case invalidParameterException(message: String?)
    case invalidTagParameterException(message: String?)
    case kmsException(message: String?)
    case layerAlreadyExistsException(message: String?)
    case layerInaccessibleException(message: String?)
    case layerPartTooSmallException(message: String?)
    case layersNotFoundException(message: String?)
    case lifecyclePolicyNotFoundException(message: String?)
    case lifecyclePolicyPreviewInProgressException(message: String?)
    case lifecyclePolicyPreviewNotFoundException(message: String?)
    case limitExceededException(message: String?)
    case referencedImagesNotFoundException(message: String?)
    case repositoryAlreadyExistsException(message: String?)
    case repositoryNotEmptyException(message: String?)
    case repositoryNotFoundException(message: String?)
    case repositoryPolicyNotFoundException(message: String?)
    case scanNotFoundException(message: String?)
    case serverException(message: String?)
    case tooManyTagsException(message: String?)
    case unsupportedImageTypeException(message: String?)
    case uploadNotFoundException(message: String?)
}

extension ECRErrorType {
    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 "EmptyUploadException":
            self = .emptyUploadException(message: message)
        case "ImageAlreadyExistsException":
            self = .imageAlreadyExistsException(message: message)
        case "ImageDigestDoesNotMatchException":
            self = .imageDigestDoesNotMatchException(message: message)
        case "ImageNotFoundException":
            self = .imageNotFoundException(message: message)
        case "ImageTagAlreadyExistsException":
            self = .imageTagAlreadyExistsException(message: message)
        case "InvalidLayerException":
            self = .invalidLayerException(message: message)
        case "InvalidLayerPartException":
            self = .invalidLayerPartException(message: message)
        case "InvalidParameterException":
            self = .invalidParameterException(message: message)
        case "InvalidTagParameterException":
            self = .invalidTagParameterException(message: message)
        case "KmsException":
            self = .kmsException(message: message)
        case "LayerAlreadyExistsException":
            self = .layerAlreadyExistsException(message: message)
        case "LayerInaccessibleException":
            self = .layerInaccessibleException(message: message)
        case "LayerPartTooSmallException":
            self = .layerPartTooSmallException(message: message)
        case "LayersNotFoundException":
            self = .layersNotFoundException(message: message)
        case "LifecyclePolicyNotFoundException":
            self = .lifecyclePolicyNotFoundException(message: message)
        case "LifecyclePolicyPreviewInProgressException":
            self = .lifecyclePolicyPreviewInProgressException(message: message)
        case "LifecyclePolicyPreviewNotFoundException":
            self = .lifecyclePolicyPreviewNotFoundException(message: message)
        case "LimitExceededException":
            self = .limitExceededException(message: message)
        case "ReferencedImagesNotFoundException":
            self = .referencedImagesNotFoundException(message: message)
        case "RepositoryAlreadyExistsException":
            self = .repositoryAlreadyExistsException(message: message)
        case "RepositoryNotEmptyException":
            self = .repositoryNotEmptyException(message: message)
        case "RepositoryNotFoundException":
            self = .repositoryNotFoundException(message: message)
        case "RepositoryPolicyNotFoundException":
            self = .repositoryPolicyNotFoundException(message: message)
        case "ScanNotFoundException":
            self = .scanNotFoundException(message: message)
        case "ServerException":
            self = .serverException(message: message)
        case "TooManyTagsException":
            self = .tooManyTagsException(message: message)
        case "UnsupportedImageTypeException":
            self = .unsupportedImageTypeException(message: message)
        case "UploadNotFoundException":
            self = .uploadNotFoundException(message: message)
        default:
            return nil
        }
    }
}

extension ECRErrorType: CustomStringConvertible {
    public var description: String {
        switch self {
        case .emptyUploadException(let message):
            return "EmptyUploadException: \(message ?? "")"
        case .imageAlreadyExistsException(let message):
            return "ImageAlreadyExistsException: \(message ?? "")"
        case .imageDigestDoesNotMatchException(let message):
            return "ImageDigestDoesNotMatchException: \(message ?? "")"
        case .imageNotFoundException(let message):
            return "ImageNotFoundException: \(message ?? "")"
        case .imageTagAlreadyExistsException(let message):
            return "ImageTagAlreadyExistsException: \(message ?? "")"
        case .invalidLayerException(let message):
            return "InvalidLayerException: \(message ?? "")"
        case .invalidLayerPartException(let message):
            return "InvalidLayerPartException: \(message ?? "")"
        case .invalidParameterException(let message):
            return "InvalidParameterException: \(message ?? "")"
        case .invalidTagParameterException(let message):
            return "InvalidTagParameterException: \(message ?? "")"
        case .kmsException(let message):
            return "KmsException: \(message ?? "")"
        case .layerAlreadyExistsException(let message):
            return "LayerAlreadyExistsException: \(message ?? "")"
        case .layerInaccessibleException(let message):
            return "LayerInaccessibleException: \(message ?? "")"
        case .layerPartTooSmallException(let message):
            return "LayerPartTooSmallException: \(message ?? "")"
        case .layersNotFoundException(let message):
            return "LayersNotFoundException: \(message ?? "")"
        case .lifecyclePolicyNotFoundException(let message):
            return "LifecyclePolicyNotFoundException: \(message ?? "")"
        case .lifecyclePolicyPreviewInProgressException(let message):
            return "LifecyclePolicyPreviewInProgressException: \(message ?? "")"
        case .lifecyclePolicyPreviewNotFoundException(let message):
            return "LifecyclePolicyPreviewNotFoundException: \(message ?? "")"
        case .limitExceededException(let message):
            return "LimitExceededException: \(message ?? "")"
        case .referencedImagesNotFoundException(let message):
            return "ReferencedImagesNotFoundException: \(message ?? "")"
        case .repositoryAlreadyExistsException(let message):
            return "RepositoryAlreadyExistsException: \(message ?? "")"
        case .repositoryNotEmptyException(let message):
            return "RepositoryNotEmptyException: \(message ?? "")"
        case .repositoryNotFoundException(let message):
            return "RepositoryNotFoundException: \(message ?? "")"
        case .repositoryPolicyNotFoundException(let message):
            return "RepositoryPolicyNotFoundException: \(message ?? "")"
        case .scanNotFoundException(let message):
            return "ScanNotFoundException: \(message ?? "")"
        case .serverException(let message):
            return "ServerException: \(message ?? "")"
        case .tooManyTagsException(let message):
            return "TooManyTagsException: \(message ?? "")"
        case .unsupportedImageTypeException(let message):
            return "UnsupportedImageTypeException: \(message ?? "")"
        case .uploadNotFoundException(let message):
            return "UploadNotFoundException: \(message ?? "")"
        }
    }
}
