-
-
Notifications
You must be signed in to change notification settings - Fork 100
Make sure set_last_error is called for .log_err() #4187
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
We have a common .log_err() trait method which is very prevalent and useful in the FFI bindings. However this was not hooked up with the set_last_error/get_last_error mechanism, which the error! macro was hooked up with. This hooks correctly hooks up the two and makes sure to log all errors around backup provider/retrieval.
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.
nice, lgtm
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.
log_err()
sends a Warning, like warn!()
, so either warn!()
should also call set_last_error()
or log_err()
should not call it.
Maybe we need to rename log_err()
, it's confusing that it generates a Warning instead of an Error.
I think you could argue that |
I agree, let's not talk about renaming
I'd like to add: We spread
So, do you propose to accept the inconsistency in order to fix #4186 and #4178? We can do this if you say it's necessary. My gut feeling would say "just use |
I don't think this is really a worry:
I don't think this is inconsistent, I think this is working as intended. The |
These functions are used as a replacement for .ok_or_log_msg(context, "Vacuum failed, exporting anyway"); would have been a pure refactoring. With this PR, it will be a semantical change. Maybe we should also make |
|
i think, this PR is good enough - it adds a single line and seems to solve all error reporting issues we have with backup sending. sure, there may be more cases where last error should be set, however, most cases that cause actual, real problems seem to be covered. and i agree, we should do refactor the error and warning handling at some point, but, as this easily comes with new bugs or annoyances, we should not do that just now, shortly before a release. offtopic: historical backgroundone cause of the issues is that core and UIs had/have different views what an error is:
to not show tons of toasts to the user, core often uses warnings instead of errors. the, maybe wrong, decision to just show all reported errors to the user, was made at the very beginning to push the first UI forward fast. meanwhile (since 2 years or so), android and ios UI do no longer report DC_EVENT_ERROR to the user - instead, in case a concrete function "fails" and failure "is expected", a "real dialog" is shown, which is better UX (but also more work). but we never changed that "officially" and also desktop was not adapted as there was no real need as both approaches kind of work. sending or connection failures, the most frequent errors, however, are reported differently and are not part of this issue at all. |
This PR here is quite a big semantical change, too: It not only changes the behavior of backup sending, but of everything that uses dc_get_last_error(): normal import/export, when Probably it's fine, but still, I would prefer if we e.g. introduced a new method for this, called That being said: I'm OK with my opinion being ignored here if we need to merge this PR because it's urgent (and error-reporting is on a best-effort basis, anyway, so while I'm afraid that this PR might introduce bugs now or make it easier to accidentally introduce bugs in the future while refactoring, they wouldn't be very severe bugs). Whoever merges this will need to use "Merge without waiting for requirements to be met (bypass branch protections)", anyway, because CI fails. |
I made an alternative: #4195 |
We have a common .log_err() trait method which is very prevalent and
useful in the FFI bindings. However this was not hooked up with the
set_last_error/get_last_error mechanism, which the error! macro was
hooked up with.
This hooks correctly hooks up the two and makes sure to log all errors
around backup provider/retrieval.
Closes #4186, #4178