Copper
  • Intro to Copper
  • Getting Started
    • Installation
    • Create Project
      • Go Templates
      • Tailwind
      • React
      • React + Tailwind
      • REST API
  • Guides
    • HackerNews Clone
    • Deploy with Fly.io
  • The Basics
    • Directory Structure
    • Dependency Injection
  • Core
    • App Lifecycle
    • Configuration
    • Error Handling
    • Logging
  • HTTP
    • Routing
    • Read & Write JSON
    • HTML Views
    • Middleware
  • SQL
    • Queries
    • Migrations
Powered by GitBook
On this page

Was this helpful?

  1. Core

Error Handling

Copper provides the cerrors package that helps add structure and context to your errors.

err := s.rockets.ThrustEngine(ctx, Engine3)
if err != nil {
    return cerrors.New(err, "failed to thrust engine", map[string]interface{}{
        "engine": Engine3,
    })
}

Always wrap your errors with a helpful message and tags before returning them. This will produce much better logs.

PreviousConfigurationNextLogging

Last updated 2 years ago

Was this helpful?