I'm seeing a lot of examples for node.js to fail a lambda using context.fail(response).
What is the c# equivalent of context.fail(response) since the ILambdaContext for c# doesn't have fail or succeed methods on it?
I'm seeing a lot of examples for node.js to fail a lambda using context.fail(response).
What is the c# equivalent of context.fail(response) since the ILambdaContext for c# doesn't have fail or succeed methods on it?
In the Node.js version 0.10.42 runtime the context contained methods for succeed
, fail
, and done
[1]. This model was replaced with a callback model which removed the methods from the context and errors are passed from a callback[2].
In the C# programming model the analogous is to throw an exception[3].
From the docs:
When an exception occurs in your Lambda function, Lambda will report the exception information back to you. Exceptions can occur in two different places:
- Initialization (Lambda loading your code, validating the handler string, and creating an instance of your class if it is non-static).
- The Lambda function invocation.
An example is given where an exception is thrown from a Handler:
namespace Example { public class AccountAlreadyExistsException : Exception { public AccountAlreadyExistsException(String message) : base(message) { } } } namespace Example { public class Handler { public static void CreateAccount() { throw new AccountAlreadyExistsException("Account is in use!"); } } }
[1]: Using Earlier Node.js Runtime (v0.10.42)
[2]: Function Errors (Node.js)
[3]: Function Errors (C#)