UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

62 lines 1.8 kB
/** * @module EventBus */ import { CORE, resolveOneOrMore, } from "../../utilities/_module-exports.js"; /** * * IMPORT_PATH: `"@daiso-tech/core/event-bus/contracts"` * @group Errors */ export class EventBusError extends Error { static deserialize(deserializedValue) { return new EventBusError(deserializedValue.message, deserializedValue.cause); } constructor(message, cause) { super(message, { cause }); this.name = EventBusError.name; } serialize() { return { name: this.name, message: this.message, cause: this.cause, }; } } /** * * IMPORT_PATH: `"@daiso-tech/core/event-bus/contracts"` * @group Errors */ export class UnexpectedEventBusError extends EventBusError { static deserialize(deserializedValue) { return new UnexpectedEventBusError(deserializedValue.message, deserializedValue.cause); } constructor(message, cause) { super(message, { cause }); this.name = UnexpectedEventBusError.name; } } /** * * IMPORT_PATH: `"@daiso-tech/core/event-bus/contracts"` * @group Errors */ export const EVENT_BUS_ERRORS = { Base: EventBusError, Unexpected: UnexpectedEventBusError, }; /** * The `registerEventBusErrorsToSerde` function registers all {@link IEventBus | `IEventBus`} related errors with `ISerderRegister`, ensuring they will properly be serialized and deserialized. * * IMPORT_PATH: `"@daiso-tech/core/event-bus/contracts"` * @group Errors */ export function registerEventBusErrorsToSerde(serde) { for (const serde_ of resolveOneOrMore(serde)) { serde_ .registerClass(EventBusError, CORE) .registerClass(UnexpectedEventBusError, CORE); } } //# sourceMappingURL=event-bus.errors.js.map