-
-
Notifications
You must be signed in to change notification settings - Fork 445
log errors also in the Fact process step #1456
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
Conversation
|
Hi @NichtJens Thanx, it sould be nice to have a more consistent and compact output but, if I don"t mess anything we loose usefull informations to debug the problem: I broke the AptSources fact for the test With this PR changes: It seems now difficult to find the problem. |
|
@maisim Mhmm... Yeah, that's not good. I guess this brings us back to my remark:
Do you by chance understand where the |
|
I think the exception here is correct, following the logic that:
However, this basically dictates that if the command executes OK the process MUST always work. But given this example:
How do we indicate failure? We can a) blow up w/exception -> this problem or b) return I don't think catching all exceptions here is going to work since we'll miss bugs. But an explicit |
|
Let's see if I got this right :) I define: class FactProcessError(RuntimeError):
pass... and change from the current PR to this: try:
data = fact.process(stdout_lines)
except FactProcessError as e:
log_error_or_warning(
...Then, I'd use it like this: class JSONFileContents(files.FileContents):
def process(self, output):
output = super().process(output)
output = "\n".join(output)
try:
output = json.loads(output)
except Exception as e:
raise FactProcessError from e
return outputProbably, we still want to log the output. This would mean, I change the current PR to this: def log_error_or_warning(
...
if exception:
cause = exception.__cause__
exc_text = "{0}: {1}".format(type(cause).__name__, cause)
log_func(
...Now only Is that correct? |
Augh sorry @NichtJens I missed this - that's exactly it 👍 |
|
@Fizzadar Awesome! I'll update the PR ASAP :) |
…mport from partially initialized module)
|
@Fizzadar ... and done. |
Fizzadar
left a comment
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.
Fantastic change, thank you @NichtJens! And thank you for the super quick turnaround :)

Currently, errors in the command step of a
Factare logged like this:Errors in the process step are raised instead*:
This PR proposes to treat these errors the same as errors in the command step:
I tried to be consistent with the styling of existing command error logging. It might be desirable to also log the full traceback, though. This would need some changes to the current logger setup since passing in
exc_infotologger.errorvialog_error_or_warningdoes not seem to work ATM. I assume this is because of the customLogHandler/LogFormatter. Either way, I think the proposed change is an improvement over the current behavior.*the code for
JSONFileContentsis:3.xat this time)scripts/dev-test.sh)scripts/dev-lint.sh)Tests will be added if the proposed changes are actually desired behavior. If not, writing tests now is probably not worth it.
I don't think the documentation needs to change.