UNPKG

glitchkit

Version:

A lightweight toolkit to create and manage expressive, structured, and reusable error types. Perfect for APIs, services, and glitchy adventures

42 lines (41 loc) 1.4 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const GlitchKitBaseError_1 = __importDefault(require("../baseGlitchKit/GlitchKitBaseError")); class GlitchKitBaseValidationError extends GlitchKitBaseError_1.default { constructor(message, errorCode) { super(message, errorCode); Object.setPrototypeOf(this, GlitchKitBaseValidationError.prototype); Error.captureStackTrace(this, this.constructor); } static isInstance(error) { return error instanceof GlitchKitBaseValidationError; } get attribute() { return this._attribute; } set attribute(value) { this._attribute = value; } get attributeValue() { return this._attributeValue; } set attributeValue(value) { this._attributeValue = value; } withAttribute(attribute) { this._attribute = attribute; return this; } withAttributeValue(value) { this._attributeValue = value; return this; } toJSON() { const jsonError = Object.assign(Object.assign({}, super.toJSON()), { attribute: this._attribute, attributeValue: this._attributeValue }); return jsonError; } } exports.default = GlitchKitBaseValidationError;