Skip to content
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

feat(minor)!: Add document reference to Error Log and doc.log_error #16653

Merged
merged 8 commits into from
Apr 20, 2022

Conversation

rmehta
Copy link
Member

@rmehta rmehta commented Apr 18, 2022

  • Added 2 properties to Error Log (reference_doctype, reference_name) to be able to track and filter source of error
  • Added a new method in document class doc.log_error(title, message)
  • Updated new API in existing framework (other than integrations)

@rmehta rmehta requested a review from a team April 18, 2022 10:10
@rmehta rmehta marked this pull request as draft April 18, 2022 10:11
@codecov
Copy link

codecov bot commented Apr 18, 2022

Codecov Report

Merging #16653 (248c355) into develop (803f1fb) will decrease coverage by 3.94%.
The diff coverage is 26.66%.

@@             Coverage Diff             @@
##           develop   #16653      +/-   ##
===========================================
- Coverage    57.37%   53.42%   -3.95%     
===========================================
  Files          762      749      -13     
  Lines        68145    67363     -782     
  Branches      5890     5711     -179     
===========================================
- Hits         39098    35991    -3107     
- Misses       25464    27226    +1762     
- Partials      3583     4146     +563     
Flag Coverage Δ
server 62.73% <26.66%> (-0.16%) ⬇️
ui-tests 36.72% <ø> (-11.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@rmehta rmehta added the Skip Manual Testing The changes in this PR does not require manual testing. label Apr 18, 2022
@rmehta rmehta marked this pull request as ready for review April 20, 2022 10:17
@rmehta rmehta merged commit 78bddb4 into frappe:develop Apr 20, 2022
@@ -1052,4 +1052,4 @@ def attach_files_to_document(doc, event):
folder="Home/Attachments",
).insert()
except Exception:
frappe.log_error(title=_("Error Attaching File"))
file_doc.log_error("Error Attaching File")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling this exception leads to a NameError since the variable file_doc won't be defined if the insert isn't successful.

Will fix this via #16289

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gavindsouza !

@@ -2068,25 +2068,36 @@ def logger(
)


def log_error(message=None, title=_("Error")):
def log_error(title=None, message=None, reference_doctype=None, reference_name=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this order switched? There are 100s of log_error calls who will check and fix them all? 🤦

Copy link
Collaborator

@sagarvora sagarvora May 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @ankush. It's used everywhere. Will make a lot of error handling fail. Doing this will also make the API inconsistent, since msgprint still has the msg first.

@ankush ankush changed the title feat(minor): Add document reference to Error Log and doc.log_error feat(minor)!: Add document reference to Error Log and doc.log_error May 2, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Skip Manual Testing The changes in this PR does not require manual testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants