fastly.error

STRING, can be read and unset, but not set.

Available inall subroutines.

Contains the last error code raised, otherwise not set.

Some functions that can raise errors don't unset fastly.error upon being called. When error-checking an important operation, you can ensure you're responding only to relevant errors by unsetting fastly.error beforehand:

declare local var.key STRING = ...;
declare local var.iv STRING = ...;
declare local var.ciphertext STRING = ...;
declare local var.plaintext STRING;
# ... unrelated calls that may produce errors ...
# Clear fastly.error before an important operation
unset fastly.error;
set var.plaintext = crypto.decrypt_hex(aes256, cbc, nopad, var.key, var.iv, var.ciphertext);
# If fastly.error is set here, we're certain it's due to the call we're concerned with
if (fastly.error == "EBADDECRYPT") {
error 403 "Wrong key";
} else if (fastly.error) {
error 503;
}

States

ValueDescription
EBADDECRYPTDecryption failed. Produced when the wrong key or IV are used.
EPARSENUMNumber parsing failed. Claimed to be produced by std.strtol but currently not possible.
ERANGENumerical result out of range.
EREGCall to regex routine failed (generic).
EREGRECURCall to regex routine failed because of recursion limits.
EREGSUBCall to regex routine failed (generic).
ESESOOMOut of workspace memory.
EDOMDomain error. This occurs for a mathematical function which is not defined for a particular value; formally, that value is not considered part of its input domain. For example, division by zero, or var.x %= 5; where var.x is a floating point infinity.
ESYNTHOOMSynthetic response overflow.
EUTF8Invalid UTF-8.
EUNAVAILData temporarily unavailable.
EINVALInvalid argument.