import { HttpStatusCodes } from "../httpStatusCodes.mjs";
import { errorData } from "./errorCodes.mjs";
import { t } from "express-intlayer";

//#region src/utils/errors/ErrorsClass.ts
/**
* Custom error class that extends the native JavaScript Error class.
* This class supports multilingual error messages and HTTP status codes.
*/
var AppError = class extends Error {
	isAppError = true;
	name;
	isMultilingual = true;
	errorKey;
	title;
	multilingualTitle;
	message;
	multilingualMessage;
	httpStatusCode;
	messageDetails;
	/**
	* Constructor for the custom error class.
	* @param multilingualMessage - The error message which can be a simple string or a multilingual object.
	* @param httpStatusCode - Optional HTTP status code, defaults to 500 Internal Server Error.
	*/
	constructor(multilingualTitle, multilingualMessage, errorKey, httpStatusCode = HttpStatusCodes.INTERNAL_SERVER_ERROR_500, messageDetails) {
		const title = t(multilingualTitle);
		const message = t(multilingualMessage);
		super(message);
		this.title = title;
		this.multilingualTitle = multilingualTitle;
		this.message = message;
		this.multilingualMessage = multilingualMessage;
		this.name = "AppError";
		this.errorKey = errorKey;
		this.httpStatusCode = httpStatusCode;
		this.messageDetails = messageDetails;
		Error.captureStackTrace(this, this.constructor);
	}
};
var GenericError = class extends AppError {
	constructor(errorKey, messageDetails) {
		const multilingualTitle = errorData[errorKey].title;
		const multilingualMessage = errorData[errorKey].message;
		const httpStatusCode = errorData[errorKey].statusCode;
		super(multilingualTitle, multilingualMessage, errorKey, httpStatusCode, messageDetails);
	}
};

//#endregion
export { AppError, GenericError };
//# sourceMappingURL=ErrorsClass.mjs.map