UNPKG

3.4 kBTypeScriptView Raw
1declare class NativeError extends global.Error { }
2
3declare module 'mongoose' {
4 import mongodb = require('mongodb');
5
6 type CastError = Error.CastError;
7 type SyncIndexesError = Error.SyncIndexesError;
8
9 export class MongooseError extends global.Error {
10 constructor(msg: string);
11
12 /** The type of error. "MongooseError" for generic errors. */
13 name: string;
14
15 static messages: any;
16
17 static Messages: any;
18 }
19
20 class Error extends MongooseError { }
21
22 namespace Error {
23
24 export class CastError extends MongooseError {
25 name: 'CastError';
26 stringValue: string;
27 kind: string;
28 value: any;
29 path: string;
30 reason?: NativeError | null;
31
32 constructor(type: string, value: any, path: string, reason?: NativeError, schemaType?: SchemaType);
33 }
34 export class SyncIndexesError extends MongooseError {
35 name: 'SyncIndexesError';
36 errors?: Record<string, mongodb.MongoServerError>;
37
38 constructor(type: string, value: any, path: string, reason?: NativeError, schemaType?: SchemaType);
39 }
40
41 export class DivergentArrayError extends MongooseError {
42 name: 'DivergentArrayError';
43 }
44
45 export class MissingSchemaError extends MongooseError {
46 name: 'MissingSchemaError';
47 }
48
49 export class DocumentNotFoundError extends MongooseError {
50 name: 'DocumentNotFoundError';
51 result: any;
52 numAffected: number;
53 filter: any;
54 query: any;
55 }
56
57 export class ObjectExpectedError extends MongooseError {
58 name: 'ObjectExpectedError';
59 path: string;
60 }
61
62 export class ObjectParameterError extends MongooseError {
63 name: 'ObjectParameterError';
64 }
65
66 export class OverwriteModelError extends MongooseError {
67 name: 'OverwriteModelError';
68 }
69
70 export class ParallelSaveError extends MongooseError {
71 name: 'ParallelSaveError';
72 }
73
74 export class ParallelValidateError extends MongooseError {
75 name: 'ParallelValidateError';
76 }
77
78 export class MongooseServerSelectionError extends MongooseError {
79 name: 'MongooseServerSelectionError';
80 }
81
82 export class StrictModeError extends MongooseError {
83 name: 'StrictModeError';
84 isImmutableError: boolean;
85 path: string;
86 }
87
88 export class ValidationError extends MongooseError {
89 name: 'ValidationError';
90
91 errors: { [path: string]: ValidatorError | CastError };
92 addError: (path: string, error: ValidatorError | CastError) => void;
93
94 constructor(instance?: MongooseError);
95 }
96
97 export class ValidatorError extends MongooseError {
98 name: 'ValidatorError';
99 properties: {
100 message: string,
101 type?: string,
102 path?: string,
103 value?: any,
104 reason?: any
105 };
106 kind: string;
107 path: string;
108 value: any;
109 reason?: MongooseError | null;
110
111 constructor(properties: {
112 message?: string,
113 type?: string,
114 path?: string,
115 value?: any,
116 reason?: any
117 });
118 }
119
120 export class VersionError extends MongooseError {
121 name: 'VersionError';
122 version: number;
123 modifiedPaths: Array<string>;
124
125 constructor(doc: Document, currentVersion: number, modifiedPaths: Array<string>);
126 }
127
128 export class StrictPopulateError extends MongooseError {
129 name: 'StrictPopulateError';
130 path: string;
131 }
132 }
133}