-
Notifications
You must be signed in to change notification settings - Fork 19
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
Refactor handling of non-fatal errors, including warnings. #337
Conversation
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.
Ironically, this looks a lot like my initial proposal :)
This looks like a good approach.
let semconv_spec = SemConvSpecWithProvenance::from_file(path_buf.as_path())?; | ||
registry.add_semconv_spec(semconv_spec); | ||
pub fn try_from_path_pattern(registry_id: &str, path_pattern: &str) -> WResult<Self, Error> { | ||
fn create_registry_or_fatal( |
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.
This pattern simplifies the management of fatal errors using a simple ?
operator. This internal method populates a list of non-fatal errors and returns a Result
. This Result
is then transformed into a WResult
depending on the presence or absence of non-fatal errors.
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.
This gets around limitations in the current expeirmental custom type ?
support for sure. I'd still like to go that direction with WResult when it stabilizes, but for now this seems to be our best bet.
I may take some time to write up a guide on using WResult that includes this, but sadly I've been highly limited on time recently (possibly when entities OTEP has progressed past prototyping, I can come back and revisit this)
Err(e) => { | ||
error.push(e); | ||
None | ||
// Process all the results of the previous parallel processing. |
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: We should turn this into a helper method eventually.
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 suggest implementing this helper once we encounter more than one instance of this pattern.
let semconv_spec = SemConvSpecWithProvenance::from_file(path_buf.as_path())?; | ||
registry.add_semconv_spec(semconv_spec); | ||
pub fn try_from_path_pattern(registry_id: &str, path_pattern: &str) -> WResult<Self, Error> { | ||
fn create_registry_or_fatal( |
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.
This gets around limitations in the current expeirmental custom type ?
support for sure. I'd still like to go that direction with WResult when it stabilizes, but for now this seems to be our best bet.
I may take some time to write up a guide on using WResult that includes this, but sadly I've been highly limited on time recently (possibly when entities OTEP has progressed past prototyping, I can come back and revisit this)
This PR introduces a new result type named
WResult
, which distinguishes between non-fatal errors (NFEs) and fatal errors. NFEs do not prevent subsequent operations from completing successfully. For example, if a semconv file is invalid, a non-fatal error is generated, but processing of the other files continues.This design will reduce the risk of promoting non-fatal errors to fatal errors, as occurred in the previous design.
With this PR:
Closes #334