Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

advanced error wrapping & handling #74

Open
samjtro opened this issue Dec 13, 2024 · 0 comments
Open

advanced error wrapping & handling #74

samjtro opened this issue Dec 13, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@samjtro
Copy link
Member

samjtro commented Dec 13, 2024

what would you like to see (describe affect rather than mechanism, if possible)?

as per @jazzboME

If we wanted to go big, the other option is that the package could define a set of custom errors and make them available to the user -- then the user could potentially use errors.Is()

     if errors.Is(err, ErrNeedReAuthorization) {
	... application could inform the user and ask for input before initiating the process again
     } 

I wrote up a quick example of what a custom error system might do, including a custom error struct, custom error messages, and two examples of errors.Is(), and how the handler might be able to leverage that to pass back more information to the caller: https://go.dev/play/p/tAJIlc1zFcL

https://go.dev/blog/go1.13-errors is the standard intro to error wrapping. Ultimately industry standard is more or less to wrap when you need to and always avoid wrapping implementation details.
@samjtro samjtro added the enhancement New feature or request label Dec 13, 2024
samjtro added a commit that referenced this issue Dec 24, 2024
- ref: #75, #74
- desc:
- added error wrapping, most of the credit goes to @jazzboME
- removed .env file usage from primary functions, added for testing only
- some misc housekeeping and assorted updates
- readme updates to reflect change
@samjtro samjtro changed the title error handling advanced error wrapping & handling Dec 24, 2024
@samjtro samjtro self-assigned this Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant