Merge pull request #16454 from resilient-tech/ignore-DoesNotExistError
fix!: ignore `DoesNotExistError` inside `get_cached_value`
This commit is contained in:
commit
16324e9cd2
2 changed files with 20 additions and 12 deletions
|
|
@ -896,7 +896,12 @@ def clear_document_cache(doctype, name):
|
|||
cache().hdel('document_cache', key)
|
||||
|
||||
def get_cached_value(doctype, name, fieldname, as_dict=False):
|
||||
doc = get_cached_doc(doctype, name)
|
||||
try:
|
||||
doc = get_cached_doc(doctype, name)
|
||||
except DoesNotExistError:
|
||||
clear_last_message()
|
||||
return
|
||||
|
||||
if isinstance(fieldname, str):
|
||||
if as_dict:
|
||||
throw('Cannot make dict for single fieldname')
|
||||
|
|
|
|||
|
|
@ -1645,18 +1645,21 @@ def validate_json_string(string: str) -> None:
|
|||
raise frappe.ValidationError
|
||||
|
||||
def get_user_info_for_avatar(user_id: str) -> Dict:
|
||||
user_info = {
|
||||
"email": user_id,
|
||||
"image": "",
|
||||
"name": user_id
|
||||
}
|
||||
try:
|
||||
user_info["email"] = frappe.get_cached_value("User", user_id, "email")
|
||||
user_info["name"] = frappe.get_cached_value("User", user_id, "full_name")
|
||||
user_info["image"] = frappe.get_cached_value("User", user_id, "user_image")
|
||||
except Exception:
|
||||
frappe.local.message_log = []
|
||||
return user_info
|
||||
user = frappe.get_cached_doc("User", user_id)
|
||||
return {
|
||||
"email": user.email,
|
||||
"image": user.user_image,
|
||||
"name": user.full_name
|
||||
}
|
||||
|
||||
except frappe.DoesNotExistError:
|
||||
frappe.clear_last_message()
|
||||
return {
|
||||
"email": user_id,
|
||||
"image": "",
|
||||
"name": user_id
|
||||
}
|
||||
|
||||
|
||||
def validate_python_code(string: str, fieldname=None, is_expression: bool = True) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue