UNPKG

@kotori-bot/core

Version:
83 lines (82 loc) 2.56 kB
/** * @Package @kotori-bot/core * @Version 1.7.2 * @Author Arimura Sena <me@hotaru.icu> * @Copyright 2024-2025 Hotaru. All rights reserved. * @License GPL-3.0 * @Link https://github.com/kotorijs/kotori * @Date 2026/2/14 15:50:13 */ "use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var error_exports = {}; __export(error_exports, { CommandError: () => CommandError, DevError: () => DevError, KotoriError: () => KotoriError, ModuleError: () => ModuleError }); module.exports = __toCommonJS(error_exports); class KotoriError extends Error { /** * Creates an instance of `KotoriError`. * * @param - Error message * @param - Error label */ constructor(message, label) { super(message); this.name = label ? `${label.charAt(0).toUpperCase()}${label.slice(1)}Error` : "KotoriError"; this.label = label; } /** Error label */ label; extend() { return new Proxy(KotoriError, { construct: (target, args, newTarget) => Reflect.construct( target, [`${this.message ? `${this.message} ` : ""}${args[0]}`, args[1] ?? this.label], newTarget ) }); } static from(err, label) { const origin = err instanceof Error ? err : new Error(String(err)); const error = new KotoriError(origin.message, label ?? origin.name); if (origin.cause) error.cause = origin.cause; if (origin.stack) error.stack = origin.stack; return error; } } const ModuleError = new KotoriError(void 0, "module").extend(); const DevError = new KotoriError(void 0, "dev").extend(); class CommandError extends KotoriError { value; constructor(value) { super(); this.value = value; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { CommandError, DevError, KotoriError, ModuleError });