General types of error - AWS Lambda

General types of error

Syntax or type errors are generally caught by compilers or surface in log files when errors occur at runtime. Most errors in this class can be caught when writing or testing the code locally, or during tests in the build process. Depending upon the runtime, an error of this type usually results in a clear error message identifying the line number of code where the problem occurred.

Typos may pass undetected by compilers and may run without errors during some invocations, depending upon the input. The cause of the error may be as simple as missing parentheses in equations or passing parameters in an incorrect order. Using human-readable variable names, visually inspecting code, and reviewing code with another developer can help identify these issues.

Implementation errors can occur when the overall logic of the application is correct but a specific task or data structure manipulation is handled incorrectly. For example, a Lambda function may process an event payload and incorrectly assume that there is always only one event in an array. As a result, the implementation fails to process part of the payload correctly.

Logic errors are a broad category of bug that can cause a Lambda function to operate incorrectly but not throw an error. The most common symptom of this type of problem is the Lambda function produces the wrong result. For example, an off-by-one error may result in a loop iterating too few or too many times. This type of error can be mitigated by writing tests for your code that use a sufficient range of likely input parameters.