Error handling and execution reporting utilities.
Provides utilities for error handling, message formatting, and execution timing to support error reporting and performance analysis.
Usage
import { error, message, time } from '@metreeca/core/report';// Throw errors in expression contextsconst value = map.get(key) ?? error("Missing required key");const result = isValid(input) ? processInput(input) : error(new ValidationError("Invalid input"));// Format values for error messagesconsole.error(`Failed with: ${message(errorValue)}`);// Error objects -> message property// Numbers -> locale-formatted strings// Other values -> string representation// Monitor execution timingconst result = await time( async () => fetchData(url), (data, elapsed) => console.log(`Fetched in ${elapsed}ms`));const computed = time( () => expensiveCalculation(), (result, elapsed) => logPerformance('calculation', elapsed)); Copy
import { error, message, time } from '@metreeca/core/report';// Throw errors in expression contextsconst value = map.get(key) ?? error("Missing required key");const result = isValid(input) ? processInput(input) : error(new ValidationError("Invalid input"));// Format values for error messagesconsole.error(`Failed with: ${message(errorValue)}`);// Error objects -> message property// Numbers -> locale-formatted strings// Other values -> string representation// Monitor execution timingconst result = await time( async () => fetchData(url), (data, elapsed) => console.log(`Fetched in ${elapsed}ms`));const computed = time( () => expensiveCalculation(), (result, elapsed) => logPerformance('calculation', elapsed));
Throws an error in expression contexts.
Extracts a readable message string from an unknown value.
Executes a task (sync or async) and monitors its execution time.
Error handling and execution reporting utilities.
Provides utilities for error handling, message formatting, and execution timing to support error reporting and performance analysis.
Usage