@mdf.js/crash
Version:
MMS - API Crash - Enhanced error management library
77 lines • 2.64 kB
TypeScript
/**
* Copyright 2024 Mytra Control S.L. All rights reserved.
*
* Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
* or at https://opensource.org/licenses/MIT.
*/
import { BaseObject, BaseOptions } from './types';
/** Class Base, manages errors in MDF Systems */
export declare class Base extends Error {
/** Base error options */
protected _options?: BaseOptions;
/** uuid error identifier */
protected _uuid: string;
/** Error name (type) */
name: string;
/** Error date */
date: Date;
/** Error subject, `'common'` as default */
subject: string;
/**
* Create a new Base error
* @param message - human friendly error message
* @param uuid - unique identifier for this particular occurrence of the problem
* @param options - enhanced error options
*/
constructor(message: string, uuid?: string | BaseOptions, options?: BaseOptions);
/** Return the info object for this error */
get info(): Record<string, unknown> | undefined;
/** Return the unique identifier associated to this instance */
get uuid(): string;
/** Return a string formatted as `name:message` */
toString(): string;
/** Return Base error in JSON format */
protected toObject(): BaseObject;
/**
* Clean the info object in order to main only values that are not included in the rest of fields
*/
private parseInfo;
/**
* Check if the message is safe to be setted
* @param message - human friendly error message
* @param uuid - UUID V4, unique identifier for this particular occurrence of the problem
* @returns
*/
private isSafeMessage;
/**
* Check if the passed UUID is valid and safe
* @param uuid - UUID V4, unique identifier for this particular occurrence of the problem
* @returns
*/
private isSafeId;
/**
* Check if the passed options are valid and safe
* @param options - options to be setted
* @returns
*/
private isSafeOptions;
/**
* Check if the name, passed in options, is valid and safe
* @param name - name of the error, used as category name
* @returns
*/
private isSafeName;
/**
* Check if the date, passed in options, is valid and safe
* @param date - date of the error
* @returns
*/
private isSafeDate;
/**
* Check if the subject, passed in options, is valid and safe
* @param subject - subject of the error, `'common' as default`
* @returns
*/
private isSafeSubject;
}
//# sourceMappingURL=BaseError.d.ts.map