GitHub
deepbox/core

Errors, Warnings & Logging

The error hierarchy, warning controls, and logger APIs that make Deepbox failures explicit and debuggable.
Operational safety

Overview

  • Every major module throws DeepboxError subclasses such as ShapeError, InvalidParameterError, NotFittedError, and ConvergenceError.
  • Warnings can be routed, filtered, or captured programmatically, which is useful for notebooks, tests, and app-level telemetry.
  • Logger hooks give you a lightweight tracing surface without introducing runtime dependencies.
type ConvergenceErrorDetails
export type ConvergenceErrorDetails = { readonly iterations?: number; readonly tolerance?: number; };
Details for convergence failures.
type ShapeErrorDetails
export type ShapeErrorDetails = { readonly expected?: Shape; readonly received?: Shape; readonly context?: string; };
Details about a shape mismatch error.
type LogEntry
export interface LogEntry { … }
A log entry produced by the logger.
type VerboseLevel
export type VerboseLevel = 0 | 1 | 2 | 3;
Lightweight logging / verbosity system for Deepbox.
type DeepboxWarning
export interface DeepboxWarning { … }
Structured warning emitted by Deepbox components.
type WarningAction
export type WarningAction = "default" | "error" | "ignore" | "always" | "once";
Action to take when a warning is emitted.
type WarningCategory
export type WarningCategory = "ConvergenceWarning" | "DataConversionWarning" | "UndefinedMetricWarning" | "FitFailedWarning" | "UserWarning";
Warning system for Deepbox.

BroadcastError

Error thrown when tensor shapes cannot be broadcast together.

ConvergenceError

Error thrown when an iterative algorithm fails to converge within the maximum allowed iterations.

DataValidationError

Error thrown when data validation fails.

DeepboxError

Base class for all Deepbox-specific errors.

DeviceError

Error thrown when an operation is requested on an unsupported or unavailable compute device.

DTypeError

Error thrown when a requested dtype is unsupported or cannot be handled by the current implementation.

IndexError

Error thrown when an invalid index is used to access tensor elements.

InvalidParameterError

Error thrown when invalid parameters are passed to a function or method.

MemoryError

Error thrown when memory allocation fails or memory limits are exceeded.

NotFittedError

Error thrown when a model or estimator is used before being fitted.

NotImplementedError

Error thrown when a method or code path exists in the public API but is not implemented yet.

ShapeError

Error thrown when tensor shapes are incompatible or invalid.

Logger

Lightweight logger for Deepbox models and utilities.

getLogHandler
export declare function getLogHandler(): LogHandler | undefined;

Get the current global log handler (undefined = console.log default).

setLogHandler
export declare function setLogHandler(handler: LogHandler | undefined): void;

Set a global log handler for all Logger instances.

catchWarnings
export declare function catchWarnings(fn: () => void): DeepboxWarning[];

Get warnings captured by a collector.

filterWarnings
export declare function filterWarnings(action: WarningAction, options?: { category?: WarningCategory; message?: string | RegExp; }): void;

Add a warning filter.

resetWarnings
export declare function resetWarnings(): void;

Remove all warning filters.

setWarningHandler
export declare function setWarningHandler(handler: WarningHandler | undefined): void;

Set a custom warning handler (replaces console.warn).

warn
export declare function warn(message: string, category?: WarningCategory, source?: string): void;

Issue a warning.

core-errors.ts
import {  Logger,  ShapeError,  catchWarnings,  warn,} from "deepbox/core";const logger = new Logger(1, "docs");logger.info("Deepbox runtime ready");const warnings = catchWarnings(() => {  warn("This is a routed Deepbox warning", "UserWarning", "docs");});console.log(warnings);console.log(new ShapeError("mismatched shapes"));