UNPKG

3.38 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 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 model?: any;
32
33 constructor(type: string, value: any, path: string, reason?: NativeError, schemaType?: SchemaType);
34 }
35 export class SyncIndexesError extends MongooseError {
36 name: 'SyncIndexesError';
37 errors?: Record<string, mongodb.MongoServerError>;
38
39 constructor(type: string, value: any, path: string, reason?: NativeError, schemaType?: SchemaType);
40 }
41
42 export class DisconnectedError extends MongooseError {
43 name: 'DisconnectedError';
44 }
45
46 export class DivergentArrayError extends MongooseError {
47 name: 'DivergentArrayError';
48 }
49
50 export class MissingSchemaError extends MongooseError {
51 name: 'MissingSchemaError';
52 }
53
54 export class DocumentNotFoundError extends MongooseError {
55 name: 'DocumentNotFoundError';
56 result: any;
57 numAffected: number;
58 filter: any;
59 query: any;
60 }
61
62 export class ObjectExpectedError extends MongooseError {
63 name: 'ObjectExpectedError';
64 path: string;
65 }
66
67 export class ObjectParameterError extends MongooseError {
68 name: 'ObjectParameterError';
69 }
70
71 export class OverwriteModelError extends MongooseError {
72 name: 'OverwriteModelError';
73 }
74
75 export class ParallelSaveError extends MongooseError {
76 name: 'ParallelSaveError';
77 }
78
79 export class ParallelValidateError extends MongooseError {
80 name: 'ParallelValidateError';
81 }
82
83 export class MongooseServerSelectionError extends MongooseError {
84 name: 'MongooseServerSelectionError';
85 }
86
87 export class StrictModeError extends MongooseError {
88 name: 'StrictModeError';
89 isImmutableError: boolean;
90 path: string;
91 }
92
93 export class ValidationError extends MongooseError {
94 name: 'ValidationError';
95
96 errors: { [path: string]: ValidatorError | CastError };
97 addError: (path: string, error: ValidatorError | CastError) => void;
98
99 constructor(instance?: MongooseError);
100 }
101
102 export class ValidatorError extends MongooseError {
103 name: 'ValidatorError';
104 properties: {
105 message: string,
106 type?: string,
107 path?: string,
108 value?: any,
109 reason?: any
110 };
111 kind: string;
112 path: string;
113 value: any;
114 reason?: MongooseError | null;
115
116 constructor(properties: {
117 message?: string,
118 type?: string,
119 path?: string,
120 value?: any,
121 reason?: any
122 });
123 }
124
125 export class VersionError extends MongooseError {
126 name: 'VersionError';
127 version: number;
128 modifiedPaths: Array<string>;
129
130 constructor(doc: Document, currentVersion: number, modifiedPaths: Array<string>);
131 }
132 }
133}