1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.CacheDisabledError = exports.DuplicateOptionsError = exports.NoDiscriminatorFunctionError = exports.PathNotInSchemaError = exports.InvalidOptionsConstructorError = exports.InvalidEnumTypeError = exports.ExpectedTypeError = exports.ResolveTypegooseNameError = exports.OptionDoesNotSupportOptionError = exports.StringLengthExpectedError = exports.FunctionCalledMoreThanSupportedError = exports.NotValidModelError = exports.RefOptionIsUndefinedError = exports.SelfContainingClassError = exports.CannotBeSymbolError = exports.InvalidPropTypeError = exports.AssertionFallbackError = exports.NoValidClassError = exports.NotAllVPOPElementsError = exports.NotStringTypeError = exports.NotNumberTypeError = exports.InvalidTypeError = void 0;
|
4 | const utils_1 = require("./utils");
|
5 |
|
6 | class InvalidTypeError extends Error {
|
7 | constructor(targetName, key, Type) {
|
8 | super(`"${targetName}.${key}"'s Type is invalid! Type is: "${(0, utils_1.toStringNoFail)(Type)}" [E009]`);
|
9 | }
|
10 | }
|
11 | exports.InvalidTypeError = InvalidTypeError;
|
12 | class NotNumberTypeError extends Error {
|
13 | constructor(targetName, key, enumKey, enumValue) {
|
14 | super(`Typeof "${targetName}.${key}" is "Number", value is undefined/null or does not have a reverse mapping! [E011]\n` +
|
15 | ` Encountered with property: "${enumKey}.${typeof enumValue}"`);
|
16 | }
|
17 | }
|
18 | exports.NotNumberTypeError = NotNumberTypeError;
|
19 | class NotStringTypeError extends Error {
|
20 | constructor(targetName, key, enumKey, enumValue) {
|
21 | super(`Typeof "${targetName}.${key}" is "String", used enum is not only Strings! [E010]\n` +
|
22 | ` Encountered with property in Enum: "${enumKey}.${typeof enumValue}"`);
|
23 | }
|
24 | }
|
25 | exports.NotStringTypeError = NotStringTypeError;
|
26 |
|
27 | class NotAllVPOPElementsError extends Error {
|
28 | constructor(name, key) {
|
29 | super(`"${name}.${key}" has not all needed Virtual Populate Options! Needed are: ${utils_1.allVirtualoptions.join(', ')} [E006]`);
|
30 | }
|
31 | }
|
32 | exports.NotAllVPOPElementsError = NotAllVPOPElementsError;
|
33 | class NoValidClassError extends TypeError {
|
34 | constructor(value) {
|
35 | super('Value is not a function or does not have a constructor! [E028]\n' + `Value: "${(0, utils_1.toStringNoFail)(value)}"`);
|
36 | }
|
37 | }
|
38 | exports.NoValidClassError = NoValidClassError;
|
39 | class AssertionFallbackError extends Error {
|
40 | constructor() {
|
41 | super('Assert failed - no custom error [E019]');
|
42 | }
|
43 | }
|
44 | exports.AssertionFallbackError = AssertionFallbackError;
|
45 |
|
46 | class InvalidPropTypeError extends Error {
|
47 | constructor(proptype, name, key, where) {
|
48 | super(`"${(0, utils_1.toStringNoFail)(proptype)}"(${where}) is invalid for "${name}.${key}" [E013]`);
|
49 | }
|
50 | }
|
51 | exports.InvalidPropTypeError = InvalidPropTypeError;
|
52 | class CannotBeSymbolError extends Error {
|
53 | constructor(name, key) {
|
54 | super(`A property key in Typegoose cannot be an symbol! ("${name}.${(0, utils_1.toStringNoFail)(key)}") [E024]`);
|
55 | }
|
56 | }
|
57 | exports.CannotBeSymbolError = CannotBeSymbolError;
|
58 | class SelfContainingClassError extends TypeError {
|
59 | constructor(name, key) {
|
60 | super('It seems like the type used is the same as the target class, which is not supported ' + `("${name}.${key}") [E004]`);
|
61 | }
|
62 | }
|
63 | exports.SelfContainingClassError = SelfContainingClassError;
|
64 | class RefOptionIsUndefinedError extends Error {
|
65 | constructor(name, key) {
|
66 | super(`Prop-Option "ref"'s value is "null" or "undefined" for "${name}.${key}" [E005]`);
|
67 | }
|
68 | }
|
69 | exports.RefOptionIsUndefinedError = RefOptionIsUndefinedError;
|
70 | class NotValidModelError extends TypeError {
|
71 | constructor(model, where) {
|
72 | super(`Expected "${where}" to be a valid mongoose.Model! (got: "${(0, utils_1.toStringNoFail)(model)}") [E025]`);
|
73 | }
|
74 | }
|
75 | exports.NotValidModelError = NotValidModelError;
|
76 | class FunctionCalledMoreThanSupportedError extends Error {
|
77 | constructor(functionName, supported, extra) {
|
78 | super(`Function "${functionName}" only supports to be called "${supported}" times with the same parameters [E003]\n${extra}`);
|
79 | }
|
80 | }
|
81 | exports.FunctionCalledMoreThanSupportedError = FunctionCalledMoreThanSupportedError;
|
82 | class StringLengthExpectedError extends TypeError {
|
83 | constructor(length, got, where, valueName) {
|
84 |
|
85 |
|
86 | const gotMessage = typeof got === 'string' ? `(String: "${got.length}")` : `(not-String: "${(0, utils_1.toStringNoFail)(got)}")`;
|
87 | super(`Expected "${valueName}" to have at least length of "${length}" (got: ${gotMessage}, where: "${where}") [E026]`);
|
88 | }
|
89 | }
|
90 | exports.StringLengthExpectedError = StringLengthExpectedError;
|
91 | class OptionDoesNotSupportOptionError extends TypeError {
|
92 | constructor(currentOption, problemOption, expected, provided) {
|
93 | super(`The Option "${currentOption}" does not support Option "${problemOption}" other than "${expected}" (provided was: "${provided}") [E027]`);
|
94 | }
|
95 | }
|
96 | exports.OptionDoesNotSupportOptionError = OptionDoesNotSupportOptionError;
|
97 | class ResolveTypegooseNameError extends ReferenceError {
|
98 | constructor(input) {
|
99 | super("Input was not a string AND didn't have a .typegooseName function AND didn't have a .typegooseName string [E014]\n" +
|
100 | `Value: "${(0, utils_1.toStringNoFail)(input)}"`);
|
101 | }
|
102 | }
|
103 | exports.ResolveTypegooseNameError = ResolveTypegooseNameError;
|
104 | class ExpectedTypeError extends TypeError {
|
105 | constructor(optionName, expected, got) {
|
106 | super(`Expected Argument "${optionName}" to have type "${expected}", got: "${(0, utils_1.toStringNoFail)(got)}" [E029]`);
|
107 | }
|
108 | }
|
109 | exports.ExpectedTypeError = ExpectedTypeError;
|
110 | class InvalidEnumTypeError extends TypeError {
|
111 | constructor(name, key, value) {
|
112 | super(`Invalid Type used for options "enum" at "${name}.${key}"! [E012]\n` +
|
113 | `Type: "${(0, utils_1.toStringNoFail)(value)}"\n` +
|
114 | 'https://typegoose.github.io/typegoose/docs/guides/error-warning-details#invalid-type-for-enum-e012');
|
115 | }
|
116 | }
|
117 | exports.InvalidEnumTypeError = InvalidEnumTypeError;
|
118 | class InvalidOptionsConstructorError extends TypeError {
|
119 | constructor(name, key, type) {
|
120 | super(`Type has a invalid "OptionsConstructor" on "${name}.${key}"! [E016]\n` + `Type: "${(0, utils_1.toStringNoFail)(type)}"`);
|
121 | }
|
122 | }
|
123 | exports.InvalidOptionsConstructorError = InvalidOptionsConstructorError;
|
124 | class PathNotInSchemaError extends Error {
|
125 | constructor(name, key) {
|
126 | super(`Path "${key}" on "${name}" does not exist in the Schema! [E030]`);
|
127 | }
|
128 | }
|
129 | exports.PathNotInSchemaError = PathNotInSchemaError;
|
130 | class NoDiscriminatorFunctionError extends Error {
|
131 | constructor(name, key) {
|
132 | super(`Path "${name}.${key}" does not have a function called "discriminator"! (Nested Discriminator cannot be applied) [E031]`);
|
133 | }
|
134 | }
|
135 | exports.NoDiscriminatorFunctionError = NoDiscriminatorFunctionError;
|
136 | class DuplicateOptionsError extends TypeError {
|
137 | constructor(duplicateAt) {
|
138 | super(`Duplicate Option definition at [${duplicateAt.join(',')}] [E032]`);
|
139 | }
|
140 | }
|
141 | exports.DuplicateOptionsError = DuplicateOptionsError;
|
142 | class CacheDisabledError extends TypeError {
|
143 | constructor(where) {
|
144 | super(`Tried using cache, but was disabled at "${where}" [E033]`);
|
145 | }
|
146 | }
|
147 | exports.CacheDisabledError = CacheDisabledError;
|
148 |
|
\ | No newline at end of file |