UNPKG

2.28 kBTypeScriptView Raw
1import { ResolutionStack } from './container';
2/**
3 * An extendable error class.
4 * @author https://github.com/bjyoungblood/es6-error/
5 */
6export declare class ExtendableError extends Error {
7 /**
8 * Constructor for the error.
9 *
10 * @param {String} message
11 * The error message.
12 */
13 constructor(message: string);
14}
15/**
16 * Base error for all Awilix-specific errors.
17 */
18export declare class AwilixError extends ExtendableError {
19}
20/**
21 * Error thrown to indicate a type mismatch.
22 * TODO(v3): remove `AwilixNotAFunctionError` and use this.
23 */
24export declare class AwilixTypeError extends AwilixError {
25 /**
26 * Constructor, takes the function name, expected and given
27 * type to produce an error.
28 *
29 * @param {string} funcDescription
30 * Name of the function being guarded.
31 *
32 * @param {string} paramName
33 * The parameter there was an issue with.
34 *
35 * @param {string} expectedType
36 * Name of the expected type.
37 *
38 * @param {string} givenType
39 * Name of the given type.
40 */
41 constructor(funcDescription: string, paramName: string, expectedType: string, givenType: any);
42 /**
43 * Asserts the given condition, throws an error otherwise.
44 *
45 * @param {*} condition
46 * The condition to check
47 *
48 * @param {string} funcDescription
49 * Name of the function being guarded.
50 *
51 * @param {string} paramName
52 * The parameter there was an issue with.
53 *
54 * @param {string} expectedType
55 * Name of the expected type.
56 *
57 * @param {string} givenType
58 * Name of the given type.
59 */
60 static assert<T>(condition: T, funcDescription: string, paramName: string, expectedType: string, givenType: any): T;
61}
62/**
63 * A nice error class so we can do an instanceOf check.
64 */
65export declare class AwilixResolutionError extends AwilixError {
66 /**
67 * Constructor, takes the registered modules and unresolved tokens
68 * to create a message.
69 *
70 * @param {string|symbol} name
71 * The name of the module that could not be resolved.
72 *
73 * @param {string[]} resolutionStack
74 * The current resolution stack
75 */
76 constructor(name: string | symbol, resolutionStack: ResolutionStack, message?: string);
77}