UNPKG

@aequum/mongoose

Version:

aequum mongoose tools for repository, pagination, CRUD/CRUDL, configs and utils

28 lines (27 loc) 1.02 kB
import { DuplicateEntryException } from '@aequum/exceptions/data'; type PossiblyMongoServerError = Error & { code: number; }; /** * Check whether if the error is a duplicate entry error from * MongoDB. * * @param err - Error to check * @returns */ export declare function isDuplicateError(err: PossiblyMongoServerError): false | RegExpMatchArray | null; /** * Check if the error is a duplicate entry error, if it * is, returns a `new DuplicateEntryException` with * passed arguments, otherwise returns the orignal error. * * @param err Error to check * @param message Message to be used in the exception * @param data Data to be shown in the exception * @param duplicatedProperties Duplicated properties * to be shown in the exeption * * @returns DuplicateEntryException|Error */ export declare function duplicateEntryExceptionOrError<ErrorInstance extends Error>(err: ErrorInstance, message?: any, data?: any, duplicatedProperties?: string[]): ErrorInstance | DuplicateEntryException; export {};