Capture Errors
Use logger.capture() to send caught errors to Logged with their message, stack, and optional metadata.
Basic usage
typescript
try {
await processPayment();
} catch (error) {
logger.capture(error);
}Logged extracts the error message, stack trace, and error name when possible. If the value is not an Error instance, Logged attempts to serialize it safely.
Add context
typescript
try {
await processPayment();
} catch (error) {
logger.capture(error, {
orderId: "ORD-123",
paymentMethod: "card",
});
}Metadata helps you debug faster by attaching request-specific or domain-specific context to the captured error.
What gets extracted
For Error objects, the SDK sends the following fields:
- message — error message
- stack — stack trace
- name — error name, for example TypeError
Avoid duplicate logs
Note
If you also use
logger.auto() or logger.interceptConsole(), the same error may be captured through multiple paths. The SDK includes basic duplicate filtering to reduce noise.