Skip to content

Conversation

@plusiv
Copy link
Contributor

@plusiv plusiv commented Aug 2, 2024

Description:

This PR improves error handling by adding specific error types and ensuring compatibility with errors.Is for better validation. The changes include:

  • Introduced custom error types:
    • ErrInvalidUUIDFormat
    • ErrInvalidURNPrefix
    • ErrInvalidBracketedFormat
    • ErrInvalidLength
  • Refactored error handling to use the new error types.
  • Updated the Parse, ParseBytes, and Validate functions to wrap errors with additional context using fmt.Errorf and %w.
  • Ensured backward compatibility by maintaining the IsInvalidLengthError function.

@plusiv plusiv requested a review from a team as a code owner August 2, 2024 23:34
Copy link
Contributor

@bormanp bormanp left a comment

Choose a reason for hiding this comment

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

I understand what you are trying to do and overall it seems like a worthy idea.

Given the number of packages that include this package I am rather paranoid about any functional change. I don't mind the custom error becoming public as that is an addition and changes nothing.

@plusiv
Copy link
Contributor Author

plusiv commented Aug 3, 2024

Hi @bormanp , I really appreciate your review and valid suggestions. I've removed some changes that were added unintentionally by my code formatter in my code editor. Additionally I've sightly modified the approach with ErrInvalidLength and ErrInvalidURNPrefix error types to keep more backward compatibility.

@plusiv plusiv requested a review from bormanp August 5, 2024 19:35
@bormanp bormanp merged commit 0e97ed3 into google:master Aug 6, 2024
tkarrass pushed a commit to tkarrass/uuid that referenced this pull request Sep 11, 2024
* feat: add error types

* fix: broken backward compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants