Files
DLE/backend/utils/error.js

13 lines
552 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Создает объект ошибки с указанным сообщением и кодом статуса
* @param {string} message - Сообщение об ошибке
* @param {number} statusCode - HTTP-код статуса (по умолчанию 500)
* @returns {Error} Объект ошибки с дополнительными свойствами
*/
function createError(message, statusCode = 500) {
const error = new Error(message);
error.statusCode = statusCode;
return error;
}
module.exports = { createError };