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

Domain errors #17255

Merged
merged 5 commits into from
May 15, 2024
Merged

Domain errors #17255

merged 5 commits into from
May 15, 2024

Conversation

SimonRichardson
Copy link
Member

This masks all sql, sqlite and dqlite errors so they're not available via errors.Is or errors.As. All errors should be trapped at the domain layer and not leaked outside. Thus the API client and server are never coupled to the underlying database errors.

Dropping the older domain errors for specific domain type errors gives more focused errors that can be trapped at the API server layer.

Checklist

  • Code style: imports ordered, good names, simple structure, etc
  • Comments saying why design decisions were made
  • Go unit tests, with comments saying what you're testing

QA steps

TEST_PACKAGES="./domain/..."  make run-go-tests

Links

Jira card: JUJU-

domain/errors.go Outdated Show resolved Hide resolved
Copy link
Member

@tlm tlm left a comment

Choose a reason for hiding this comment

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

lgtm

domain/errors_test.go Show resolved Hide resolved
domain/network/errors/errors.go Outdated Show resolved Hide resolved
This masks all sql, sqlite and dqlite errors so they're not available
via errors.Is or errors.As. All errors should be trapped at the domain
layer and not leaked outside. Thus the API client and server are never
coupled to the underlying database errors.

Dropping the older domain errors for specific domain type errors gives
more focused errors that can be trapped at the API server layer.
We're dropping support for centeralized domain errors, so network
needs it's own ones now.
This adds a test to ensure that sql.ErrNoRows and other database
sql errors are also not selectable.

The error message is also preserved. This prevents the need for
logging the error as well as returning the error.
The object store was leaking a sql error, ensure that we correctly
trap the error.
@SimonRichardson
Copy link
Member Author

/merge

@jujubot jujubot merged commit a22c536 into juju:main May 15, 2024
15 of 17 checks passed
@SimonRichardson SimonRichardson deleted the fix-domain-errors branch May 15, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants