-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(allsrv): add github.com/jsteenb2/errors module to improve error…
… handling The addition of this module gives us radically improved error handling and logging. We now have the ability to tie into the std lib errors.Is/As functionality instead of writing it ourselves. Our `ErrKinds` are now useful for an entire domain. We've added a touch more structure to our error handling with the new module. With this new structure we can improve our logging once again. The better your error handling is, the better your logging will get. Here's an example pulled from the service create foo with exists test: ```json { "time": "2024-07-05T22:56:16.976262-05:00", "level": "ERROR", "msg": "failed to create foo", "input_name": "existing-foo", "input_note": "new note", "took_ms": "0s", "err": "foo exists", "err_fields": { "sqlite_err_code": "constraint failed", "sqlite_err_extended_code": "constraint failed", "sqlite_system_errno": "errno 0", "err_kind": "exists", "stack_trace": [ "github.com/jsteenb2/mess/allsrv/svc.go:97[(*Service).CreateFoo]", "github.com/jsteenb2/mess/allsrv/db_sqlite.go:38[(*sqlDB).CreateFoo]", "github.com/jsteenb2/mess/allsrv/db_sqlite.go:96[(*sqlDB).exec]" ] } } ``` As your system gets more and more complex, your errors are capable of extending not support additional details. The extensibility is amazing for a growing codebase. Refs: [errors module](https://github.com/jsteenb2/errors)
- Loading branch information
Showing
13 changed files
with
140 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.