Skip to content

Commit

Permalink
show underlying error when component is not picklable
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdoc authored and adamghill committed Oct 8, 2021
1 parent 361fb1c commit 68591f0
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions django_unicorn/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,12 @@ def get_cacheable_component(

if component.parent:
component.parent = get_cacheable_component(component.parent)

try:
pickle.dumps(component)
except TypeError as e:
raise UnicornCacheError(
"Cannot cache component because it is not picklable."
) from e
except AttributeError as e:
raise UnicornCacheError(
"Cannot cache component because it is not picklable."
) from e
except NotImplementedError as e:
raise UnicornCacheError(
"Cannot cache component because it is not picklable."
) from e
except pickle.PicklingError as e:
except (TypeError, AttributeError, NotImplementedError, pickle.PicklingError) as e:
raise UnicornCacheError(
"Cannot cache component because it is not picklable."
f"Cannot cache component '{type(component)}' because it is not picklable: {type(e)}: {e}"
) from e

return component
Expand Down

0 comments on commit 68591f0

Please sign in to comment.