Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.
|
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||
|
|
// SPDX-License-Identifier: Apache-2.0
|
||
|
|
|
||
|
|
// snippet-start:[swift.lambda-basics.errors]
|
||
|
|
/// Errors thrown by the example's functions.
|
||
|
|
enum ExampleError: Error {
|
||
|
|
/// An AWS Lambda function with the specified name already exists.
|
||
|
|
case functionAlreadyExists
|
||
|
|
/// The specified role doesn't exist.
|
||
|
|
case roleNotFound
|
||
|
|
/// Unable to create the role.
|
||
|
|
case roleCreateError
|
||
|
|
/// Unable to delete the role.
|
||
|
|
case deleteRoleError
|
||
|
|
/// Unable to attach a policy to the role.
|
||
|
|
case policyError
|
||
|
|
/// Unable to get the executable directory.
|
||
|
|
case executableNotFound
|
||
|
|
/// An error occurred creating a lambda function.
|
||
|
|
case createLambdaError
|
||
|
|
/// An error occurred invoking the lambda function.
|
||
|
|
case invokeError
|
||
|
|
/// No answer received from the invocation.
|
||
|
|
case noAnswerReceived
|
||
|
|
/// Unable to list the AWS Lambda functions.
|
||
|
|
case listFunctionsError
|
||
|
|
/// Unable to update the AWS Lambda function.
|
||
|
|
case updateFunctionError
|
||
|
|
/// Unable to load the AWS Lambda function's Zip file.
|
||
|
|
case zipFileReadError
|
||
|
|
|
||
|
|
var errorDescription: String? {
|
||
|
|
switch self {
|
||
|
|
case .functionAlreadyExists:
|
||
|
|
return "An AWS Lambda function with that name already exists."
|
||
|
|
case .roleNotFound:
|
||
|
|
return "The specified role doesn't exist."
|
||
|
|
case .deleteRoleError:
|
||
|
|
return "Unable to delete the AWS IAM role."
|
||
|
|
case .roleCreateError:
|
||
|
|
return "Unable to create the specified role."
|
||
|
|
case .policyError:
|
||
|
|
return "An error occurred attaching the policy to the role."
|
||
|
|
case .executableNotFound:
|
||
|
|
return "Unable to find the executable program directory."
|
||
|
|
case .createLambdaError:
|
||
|
|
return "An error occurred creating a lambda function."
|
||
|
|
case .invokeError:
|
||
|
|
return "An error occurred invoking a lambda function."
|
||
|
|
case .noAnswerReceived:
|
||
|
|
return "No answer received from the lambda function."
|
||
|
|
case .listFunctionsError:
|
||
|
|
return "Unable to list the AWS Lambda functions."
|
||
|
|
case .updateFunctionError:
|
||
|
|
return "Unable to update the AWS lambda function."
|
||
|
|
case .zipFileReadError:
|
||
|
|
return "Unable to read the AWS Lambda function."
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// snippet-end:[swift.lambda-basics.errors]
|