Skip to main content

Error Handling

Asset Reality’s coding standards enforce robust error handling practices across all backend services. This ensures that improper error handling, such as exposing sensitive information or unhandled exceptions, is avoided.

  1. Structured Error Types

    The platform defines centralised, reusable error types in a shared Errors package. Errors includes a consistent structure with HTTP status codes and safe, user-facing messages.

  2. Safe API Responses

    Error responses returned to clients avoid exposing internal stack traces or Go error messages. Handlers use typed error wrappers to return sanitised messages and appropriate status codes.

  3. Centralised Panic Recovery The platform makes use of the chi router package and uses Chi’s Recoverer middleware to catch panics and prevent application crashes. Unexpected issues are intercepted and transformed into safe 500 responses.

  4. External Error Reporting

    Errors are logged using logrus.WithError(err) across handlers and middleware. These logs are forwarded to the logging service and to Datadog. This ensures that all unexpected behaviors, including panics and internal errors, are observable and can trigger alerts through Datadog’s log management system.

  5. Consistent Use Across Services These error handling strategies are applied across services, providing consistent behavior and observability.