Skip to content

create core/errors package#128

Draft
justinwon777 wants to merge 3 commits into
mainfrom
justin.won/core-errors
Draft

create core/errors package#128
justinwon777 wants to merge 3 commits into
mainfrom
justin.won/core-errors

Conversation

@justinwon777

@justinwon777 justinwon777 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Introduces a new core/errors package that defines:

  • ClassifiedError struct wrapping any error with ErrorType and Reason fields for metrics
  • New(errorType, reason string, err error) constructor
  • Pre-constructed User and Infra sentinel vars (no-arg messages)
  • Named struct types for all Handleable-Structured errors (User and Infra)
    so callers can use errors.As to extract specific fields

This package will replace core/common's ClassifiedError interface and
WithReason function, and all bare fmt.Errorf/errors.New call sites,
in a follow-up change.

Current failure reasons are copied from common package. Follow up will expand the list so we don't have unknown failures.

Test Plan

Unit tests

Issue

https://linear.app/uber/issue/TANGO-4/improve-tango-error-reporting

justinwon777 and others added 2 commits June 29, 2026 17:30
Introduces a new core/errors package that defines:
- ClassifiedError struct wrapping any error with ErrorType and Reason fields for metrics
- New(errorType, reason string, err error) constructor
- Pre-constructed User and Infra sentinel vars (no-arg messages)
- Named struct types for all Handleable-Structured errors (User and Infra)
  so callers can use errors.As to extract specific fields

This package will replace core/common's ClassifiedError interface and
WithReason function, and all bare fmt.Errorf/errors.New call sites,
in a follow-up change.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Restore ErrParseTimestamp and ErrPRCommitHistory as typed structs
  with Cause field so callers can type-discriminate via errors.As
- Add errors_test.go covering: New constructor, errors.As/Is traversal
  through ClassifiedError, sentinel identity, and Error() strings for
  all structured types

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@justinwon777 justinwon777 requested review from a team as code owners June 30, 2026 00:53
@CLAassistant

CLAassistant commented Jun 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@justinwon777 justinwon777 changed the title Justin.won/core errors Jun 30, 2026
@justinwon777 justinwon777 force-pushed the justin.won/core-errors branch from d0e4bfe to 17f5794 Compare June 30, 2026 00:55
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@justinwon777 justinwon777 force-pushed the justin.won/core-errors branch from 17f5794 to bc5ac9c Compare June 30, 2026 00:56

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz schedule Design Review for errors processing/classification before implementation.
alternatively, come up with an rfc-only PR

Comment thread core/errors/errors.go
FailureReasonUnknown = "unknown"
FailureReasonStorage = "storage"
FailureReasonValidation = "validation"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should type and reason be custom types (enums) then

Comment thread core/errors/errors.go
Err error
}

func (e *ClassifiedError) Error() string { return e.Err.Error() }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anything exported should have a doc

Comment thread core/errors/errors.go
func (e *ClassifiedError) Error() string { return e.Err.Error() }
func (e *ClassifiedError) Unwrap() error { return e.Err }

// New constructs a ClassifiedError.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain usage i.e. args

Comment thread core/errors/errors.go
ErrFirstRevisionRequired = New(ErrorTypeUser, FailureReasonValidation, stderrors.New("first revision is required"))
ErrSecondRevisionRequired = New(ErrorTypeUser, FailureReasonValidation, stderrors.New("second revision is required"))
ErrFirstRevisionRemoteRequired = New(ErrorTypeUser, FailureReasonValidation, stderrors.New("first revision remote is required"))
ErrFirstRevisionBaseSHARequired = New(ErrorTypeUser, FailureReasonValidation, stderrors.New("first revision base_sha is required"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why need for niche sentinels to be in a global package?

@justinwon777 justinwon777 marked this pull request as draft June 30, 2026 17:41
@justinwon777

Copy link
Copy Markdown
Contributor Author

plz schedule Design Review for errors processing/classification before implementation. alternatively, come up with an rfc-only PR

This is WIP and I'm reviewing the design with Sung today. Changed it to draft state. I can let you know once it's ready.

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

Labels

None yet

3 participants