🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@autometa/errors

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@autometa/errors

Error utilities for Autometa runtimes.

rc
npmnpm
Version
1.0.0-rc.2
Version published
Weekly downloads
177
25.53%
Maintainers
1
Weekly downloads
 
Created
Source

@autometa/errors

Robust error primitives used across the Autometa ecosystem.

Installation

pnpm add @autometa/errors

Usage

import {
	AutomationError,
	formatErrorCauses,
	formatErrorTree,
	printErrorTree,
	raise,
	safe,
	safeAsync,
} from "@autometa/errors";

function loadConfig(path: string) {
	const result = safe(() => readFileSync(path, "utf8"));
	if (!result.ok) {
			raise("Failed to load configuration", { cause: result.error });
	}
	return result.value;
}

try {
	loadConfig("./app.json");
} catch (error) {
	const automation = AutomationError.wrap(error);
	console.error(formatErrorCauses(automation, { includeStack: false }));
	printErrorTree(automation, { includeStack: false });
}

API highlights

  • AutomationError – first-class error base with helpers to detect (isAutomationError) and wrap unknown values (wrap).
  • raise – construct and throw AutomationError or custom subclasses (legacy constructors supported) with optional nested causes.
  • safe/safeAsync – execute functions, capturing failures as AutomationError instances while returning a discriminated union result.
  • formatErrorCauses – produce readable multi-line descriptions of error chains with configurable stack inclusion and depth limits.
  • formatErrorTree / printErrorTree – pretty-print error causes as an indented tree, ideal for console or structured logs.

FAQs

Package last updated on 15 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts