Skip to content

Use errorCode/SQLState from Java exceptions in stack signatures (case-insensitive @ext lookup) #2680

Open

Description

@ejsmith

Problem

ErrorSignature.AddSpecialCaseDetails adds Number and ErrorCode from an error's extended data (@ext) to the signature, so database errors with different codes get different stacks: ErrorSignature.cs#L202-L213.

The lookup is case-sensitive and only knows the .NET property names. The Java client sends exception properties under their Java bean names. So for java.sql.SQLException, @ext contains errorCode and sqlState, neither of which matches. For example, a MySQL duplicate-key error (errorCode 1062) and a deadlock (errorCode 1213) thrown from the same repository method end up in the same stack.

Proposal

  • Look up @ext keys case-insensitively (StringComparer.OrdinalIgnoreCase), so errorCode matches ErrorCode.
  • Also use SQLState when present (sqlState from JDBC; SqlState from Npgsql.PostgresException and MySqlException on .NET). It's the portable error class across JDBC drivers and makes useful signatures for Postgres errors.

Notes

  • This changes the signature hash for errors that carry these properties, so existing stacks for them will split once.
  • The client could rename the keys instead, but a case-insensitive server lookup covers every client (Java, Kotlin, and anything else that sends camelCase) without special cases.

Context: exceptionless/Exceptionless.Java#91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions