1 | import { VError } from "verror";
|
2 | /**
|
3 | * Possible FaastError names. See {@link FaastError}. To test for errors
|
4 | * matching these names, use the static method
|
5 | * {@link FaastError}.hasCauseWithName().
|
6 | * @public
|
7 | */
|
8 | export declare enum FaastErrorNames {
|
9 | /** Generic error. See {@link FaastError}. */
|
10 | EGENERIC = "VError",
|
11 | /** The arguments passed to the cloud function could not be serialized without losing information. */
|
12 | ESERIALIZE = "FaastSerializationError",
|
13 | /** The remote cloud function timed out. */
|
14 | ETIMEOUT = "FaastTimeoutError",
|
15 | /** The remote cloud function exceeded memory limits. */
|
16 | EMEMORY = "FaastOutOfMemoryError",
|
17 | /** The function invocation was cancelled by user request. */
|
18 | ECANCEL = "FaastCancelError",
|
19 | /** The exception was thrown by user's remote code, not by faast.js or the cloud provider. */
|
20 | EEXCEPTION = "UserException",
|
21 | /** Could not create the remote cloud function or supporting infrastructure. */
|
22 | ECREATE = "FaastCreateFunctionError",
|
23 | /** The remote cloud function failed to execute because of limited concurrency. */
|
24 | ECONCURRENCY = "FaastConcurrencyError"
|
25 | }
|
26 | /**
|
27 | * FaastError is a subclass of VError (https://github.com/joyent/node-verror).
|
28 | * that is thrown by faast.js APIs and cloud function invocations.
|
29 | * @remarks
|
30 | * `FaastError` is a subclass of
|
31 | * {@link https://github.com/joyent/node-verror | VError}, which provides an API
|
32 | * for nested error handling. The main API is the same as the standard Error
|
33 | * class, namely the err.message, err.name, and err.stack properties.
|
34 | *
|
35 | * Several static methods on {@link FaastError} are inherited from VError:
|
36 | *
|
37 | * FaastError.fullStack(err) - property provides a more detailed stack trace
|
38 | * that include stack traces of causes in the causal chain.
|
39 | *
|
40 | * FaastError.info(err) - returns an object with fields `functionName`, `args`,
|
41 | * and `logUrl`. The `logUrl` property is a URL pointing to the logs for a
|
42 | * specific invocation that caused the error.`logUrl` will be surrounded by
|
43 | * whitespace on both sides to ease parsing as a URL by IDEs.
|
44 | *
|
45 | * FaastError.hasCauseWithName(err, cause) - returns true if the FaastError or
|
46 | * any of its causes includes an error with the given name, otherwise false. All
|
47 | * of the available names are in the enum {@link FaastErrorNames}. For example,
|
48 | * to detect if a FaastError was caused by a cloud function timeout:
|
49 | *
|
50 | * ```typescript
|
51 | * FaastError.hasCauseWithName(err, FaastErrorNames.ETIMEOUT)
|
52 | * ```
|
53 | *
|
54 | * FaastError.findCauseByName(err, cause) - like FaastError.hasCauseWithName()
|
55 | * except it returns the Error in the causal chain with the given name instead
|
56 | * of a boolean, otherwise null.
|
57 | *
|
58 | * @public
|
59 | */
|
60 | export declare class FaastError extends VError {
|
61 | }
|
62 | export declare function synthesizeFaastError({ errObj, logUrl, functionName, args }: {
|
63 | errObj: any;
|
64 | logUrl?: string;
|
65 | functionName?: string;
|
66 | args?: any[];
|
67 | }): FaastError;
|