Back to all reviewers

log complete error objects

adonisjs/core
Based on 4 comments
TypeScript

Always log complete error objects rather than just error messages to preserve stack traces, error codes, and debugging context. Use the application's logger instead of hardcoded console statements in modules.

Logging TypeScript

Reviewer Prompt

Always log complete error objects rather than just error messages to preserve stack traces, error codes, and debugging context. Use the application’s logger instead of hardcoded console statements in modules.

When catching errors, log the entire error object to capture all available debugging information:

// ❌ Avoid - loses valuable debugging context
catch (error) {
  this.logger.error(`unable to install dependencies: ${error.message}`)
}

// ✅ Preferred - preserves complete error information
catch (error) {
  this.logger.fatal(error)
  // or with additional context
  this.logger.error('Unable to install dependencies', error)
}

Modern loggers can handle error objects properly without manual formatting like JSON.stringify(). Reserve console methods only for user-facing messages that must remain separate from structured application logs.

4
Comments Analyzed
TypeScript
Primary Language
Logging
Category

Source Discussions