-
Notifications
You must be signed in to change notification settings - Fork 111
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
Fix table-related error messages #3524
Conversation
I noted something else, and would like some feedback on that: The table-related errors that are handled here are printed twice to the console, and this is likely also occurring to other errors that are raised by throwing
Here the exception is caught, printed and thrown again. It is then caught and printed again, after reading the deck, in
My intuition would be that the error should not be caught, printed and thrown again in the first piece of code, and only be printed after reading the deck. However, I would hesitate to remove the first printing it in fear of loosing the error reporting in other code. |
I have noticed the double printing of messages, and it seems you have identified the culprit. Removing it is very welcome from my end. If nobody can clarify your concern about removing too much, I am happy to be a test runner for checking it. |
Then I propose to wait shortly if anybody else has input on this. Meanwhile I can add a commit to remove the double printing to test if that breaks anything immediately. |
Sounds like a plan :) |
e6f5713
to
aae6284
Compare
jenkins build this please |
Do I need to be white-listed for this? |
jenkins build this please |
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 think I'd personally prefer not adding the colons to the diagnostic messages, but that aside I'm a little concerned about the revised exception handling here. I think we should do a careful review before making the changes proposed here.
catch (const OpmInputError& opm_error) { | ||
OpmLog::error(opm_error.what()); | ||
throw; | ||
} | ||
catch (const std::exception& std_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.
Class OpmInputError
inherits from std::exception
. Removing the OpmInputError
clause will just mean that we end up in the std::exception
clause instead. That's unlikely to do any good, so we'll have to rethink this approach.
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.
You are correct, the wrong fix ended up in the commit, the intention was to only remove the logging call. Fixed that.
} catch (const std::runtime_error& err) { | ||
} catch (const std::invalid_argument& err) { |
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 don't think this is a valid transformation. You'll have to ensure that any exceptions thrown from the TableType
constructor (or the addTable()
function call, for that matter) that are not invalid_argument
can safely propagate to the caller. Unless you've already done that I'd be wary to do this.
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 am not very familiar with this code, but I assumed the intention of this particular snippet was to transform errors reported in the table code to add location information. Since the table code uses invalid_argument
exceptions those would need to be caught and not runtime_error
which is not thrown there afaik.
If there is a need is to add location information to a broader spectrum of exceptions, then these need to caught also, but it is not clear to me what exceptions would need to be caught. We could catch std::exception
to turn anything into OpmInputError
, but I am not that familiar with OPM error handling, not sure if that is desirable.
e30aa62
to
a89313d
Compare
That is fair, and I do not mind either way. In this case I tried to harmonize the formatting of the error messages. If somebody makes the decision on how we want it, I will fix to abide. |
I agree, that is why I indicated initially that I am not sure if this may have unintended consequences. Removing this logging call may lead to lost error messages in another context. Alternative would be to leave it and not report in |
I think is good to be consistent with the other error messages. If we decide to change the style, we could do it in a later PR for all error messages, not only this table related errors. |
Maybe you could make a separate PR with the removal of double printed messages to be further tested? Meanwhile we could already get the error location information that are relevant for the users in. |
The changes apply to the printing of all errors thrown via |
Yes, that seems like a good idea. |
For what it's worth, Issue #3239 also notes the "double printing" problem. |
a89313d
to
6842257
Compare
I have removed the commits that handle formatting and double printing. I will make separate PRs for those. This PR now only handles the error handling for the table related error messages. It does that by adding a catch block for transforming Any other exception is let to propagate as before, and will be handled eventually, just without location information. Those could be included by catching a broader spectrum of exceptions, but I am not sure which those should be and I am wary of catching all exceptions. I would suggest taking action when that occurs and more errors are observed without location information. |
1d4cbac
to
3ee4792
Compare
jenkins build this please |
3ee4792
to
fb4514a
Compare
jenkins build this please |
thanks a lot. Having line and file information there really helps a lot. Without it the error is rather useless. Merging. |
This PR fixes missing location information in the table-related code