-
Notifications
You must be signed in to change notification settings - Fork 46
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
editoast: refactor core error #11041
base: dev
Are you sure you want to change the base?
Conversation
69b2431
to
83d7f73
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## dev #11041 +/- ##
==========================================
- Coverage 80.63% 80.62% -0.02%
==========================================
Files 1099 1102 +3
Lines 112187 112362 +175
Branches 745 747 +2
==========================================
+ Hits 90460 90589 +129
- Misses 21684 21730 +46
Partials 43 43
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a869efc
to
17959f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Some comment, but mostly unrelated to the work of this PR, could be addressed in another PR.
MqClientError(#[from] MqClientError), | ||
|
||
#[error(transparent)] | ||
StandardCoreError(#[from] StandardCoreError), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Standard" feels vague, especially since there is also a variant "Generic". Not sure what each does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm wrong I think we could remove the other GenericCoreError
and only keep the StandardCoreError
one (maybe simply Core
would suffice as a name?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the difference but since they have the same meaning I believe we could replace GenericCoreError
(it was created at a time when Core errors weren't homogeneous if I recall correctly)
17959f4
to
d32fff5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for resuming the work on the split in crates!
MqClientError(#[from] MqClientError), | ||
|
||
#[error(transparent)] | ||
StandardCoreError(#[from] StandardCoreError), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm wrong I think we could remove the other GenericCoreError
and only keep the StandardCoreError
one (maybe simply Core
would suffice as a name?)
ab5c613
to
2dfb381
Compare
Signed-off-by: hamz2a <[email protected]>
2dfb381
to
1263fcd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the changes!
if let Error::StandardCoreError(standard_core_error) = result { | ||
assert_eq!(standard_core_error, expected_error); | ||
} else { | ||
panic!("Unexpected error type: {:?}", result); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: using assert_eq with the Error
variant would be more idiomatic than if-else panicking imo
@@ -290,6 +292,65 @@ impl EditoastError for editoast_models::model::Error { | |||
} | |||
} | |||
|
|||
impl EditoastError for core::Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inventory::submit!
is missing for translation keys, a few examples in this file or in macro expansion of EeitoastError
core::Error::UnparsableErrorOutput => Default::default(), | ||
core::Error::ConnectionClosedBeforeMessageCompleted => Default::default(), | ||
core::Error::ConnectionResetByPeer => Default::default(), | ||
core::Error::BrokenPipe => Default::default(), | ||
core::Error::MqClientError(_) => Default::default(), | ||
core::Error::StandardCoreError(_) => Default::default(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core::Error::UnparsableErrorOutput => Default::default(), | |
core::Error::ConnectionClosedBeforeMessageCompleted => Default::default(), | |
core::Error::ConnectionResetByPeer => Default::default(), | |
core::Error::BrokenPipe => Default::default(), | |
core::Error::MqClientError(_) => Default::default(), | |
core::Error::StandardCoreError(_) => Default::default(), | |
_ => Default::default(), |
pub struct CoreErrorResponse { | ||
#[serde(with = "StatusCodeRemoteDef", default = "default_status_code")] | ||
#[schema(value_type = u16, minimum = 100, maximum = 599)] | ||
pub status: StatusCode, | ||
#[serde(rename = "type")] | ||
pub error_type: String, | ||
pub context: HashMap<String, Value>, | ||
pub message: String, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub(in crate::views)
when necessary
@@ -1,4 +1,5 @@ | |||
mod authz; | |||
pub mod core_error_response; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub mod core_error_response; | |
mod core_error_response; | |
use core_error_response::CoreErrorResponse; |
avoids repetition in import paths
pub message: String, | ||
} | ||
|
||
impl From<Error> for CoreErrorResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl From<Error> for CoreErrorResponse { | |
impl From<core::Error> for CoreErrorResponse { |
closes #10868