Files
quantumbotx/node_modules/fault/index.js
T
Reynov Christian 78737b6835 Refactor and update bot management and routing
- Update `.gitignore` to include `lab/` for backtesting and raw data.
- Refactor `app.py` to improve error handling and logging.
- Remove deprecated files: `core/bot_logic.py`, `core/bots/base_bot.py`, `core/bots/manager.py`, `core/db/database.py`, `core/routes/api_analysis.py`, `core/routes/api_bots_analysis.py`, `core/strategies/logic_ma.py`, `core/strategies/logic_rsi.py`.
- Modify multiple files to enhance bot management, routing, and strategy handling.
- Update JavaScript and HTML templates for better UI and functionality.
2025-07-31 21:33:44 +08:00

42 lines
1.0 KiB
JavaScript

// @ts-expect-error
import formatter from 'format'
export const fault = Object.assign(create(Error), {
eval: create(EvalError),
range: create(RangeError),
reference: create(ReferenceError),
syntax: create(SyntaxError),
type: create(TypeError),
uri: create(URIError)
})
/**
* Create a new `EConstructor`, with the formatted `format` as a first argument.
*
* @template {Error} Fault
* @template {new (reason: string) => Fault} Class
* @param {Class} Constructor
*/
export function create(Constructor) {
/** @type {string} */
// @ts-expect-error
FormattedError.displayName = Constructor.displayName || Constructor.name
return FormattedError
/**
* Create an error with a printf-like formatted message.
*
* @param {string|null} [format]
* Template string.
* @param {...unknown} values
* Values to render in `format`.
* @returns {Fault}
*/
function FormattedError(format, ...values) {
/** @type {string} */
const reason = format ? formatter(format, ...values) : format
return new Constructor(reason)
}
}