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

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

import SotoCore

/// Error enum for LakeFormation
public struct LakeFormationErrorType: AWSErrorType {
    enum Code: String {
        case accessDeniedException = "AccessDeniedException"
        case alreadyExistsException = "AlreadyExistsException"
        case concurrentModificationException = "ConcurrentModificationException"
        case entityNotFoundException = "EntityNotFoundException"
        case expiredException = "ExpiredException"
        case glueEncryptionException = "GlueEncryptionException"
        case internalServiceException = "InternalServiceException"
        case invalidInputException = "InvalidInputException"
        case operationTimeoutException = "OperationTimeoutException"
        case resourceNotReadyException = "ResourceNotReadyException"
        case resourceNumberLimitExceededException = "ResourceNumberLimitExceededException"
        case statisticsNotReadyYetException = "StatisticsNotReadyYetException"
        case throttledException = "ThrottledException"
        case transactionCanceledException = "TransactionCanceledException"
        case transactionCommitInProgressException = "TransactionCommitInProgressException"
        case transactionCommittedException = "TransactionCommittedException"
        case workUnitsNotReadyYetException = "WorkUnitsNotReadyYetException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize LakeFormation
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// Access to a resource was denied.
    public static var accessDeniedException: Self { .init(.accessDeniedException) }
    /// A resource to be created or added already exists.
    public static var alreadyExistsException: Self { .init(.alreadyExistsException) }
    /// Two processes are trying to modify a resource simultaneously.
    public static var concurrentModificationException: Self { .init(.concurrentModificationException) }
    /// A specified entity does not exist
    public static var entityNotFoundException: Self { .init(.entityNotFoundException) }
    /// Contains details about an error where the query request expired.
    public static var expiredException: Self { .init(.expiredException) }
    /// An encryption operation failed.
    public static var glueEncryptionException: Self { .init(.glueEncryptionException) }
    /// An internal service error occurred.
    public static var internalServiceException: Self { .init(.internalServiceException) }
    /// The input provided was not valid.
    public static var invalidInputException: Self { .init(.invalidInputException) }
    /// The operation timed out.
    public static var operationTimeoutException: Self { .init(.operationTimeoutException) }
    /// Contains details about an error related to a resource which is not ready for a transaction.
    public static var resourceNotReadyException: Self { .init(.resourceNotReadyException) }
    /// A resource numerical limit was exceeded.
    public static var resourceNumberLimitExceededException: Self { .init(.resourceNumberLimitExceededException) }
    /// Contains details about an error related to statistics not being ready.
    public static var statisticsNotReadyYetException: Self { .init(.statisticsNotReadyYetException) }
    /// Contains details about an error where the query request was throttled.
    public static var throttledException: Self { .init(.throttledException) }
    /// Contains details about an error related to a transaction that was cancelled.
    public static var transactionCanceledException: Self { .init(.transactionCanceledException) }
    /// Contains details about an error related to a transaction commit that was in progress.
    public static var transactionCommitInProgressException: Self { .init(.transactionCommitInProgressException) }
    /// Contains details about an error where the specified transaction has already been committed and cannot be used for UpdateTableObjects.
    public static var transactionCommittedException: Self { .init(.transactionCommittedException) }
    /// Contains details about an error related to work units not being ready.
    public static var workUnitsNotReadyYetException: Self { .init(.workUnitsNotReadyYetException) }
}

extension LakeFormationErrorType: Equatable {
    public static func == (lhs: LakeFormationErrorType, rhs: LakeFormationErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension LakeFormationErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
