File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed
lib/error_tracker/schemas Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -53,19 +53,23 @@ defmodule ErrorTracker.Occurrence do
5353 :sqlite -> Application . get_env ( :ecto_sqlite3 , :json_library , Jason )
5454 end )
5555
56- case json_encoder . encode_to_iodata ( context ) do
57- { :ok , _ } ->
58- put_change ( changeset , :context , context )
59-
60- { :error , _ } ->
61- Logger . warning (
62- "[ErrorTracker] Context has been ignored: it is not serializable to JSON."
63- )
64-
65- put_change ( changeset , :context , % {
66- error: "Context not stored because it contains information not serializable to JSON."
67- } )
68- end
56+ validated_context =
57+ try do
58+ _iodata = json_encoder . encode_to_iodata! ( context )
59+ context
60+ rescue
61+ _e in Protocol.UndefinedError ->
62+ Logger . warning (
63+ "[ErrorTracker] Context has been ignored: it is not serializable to JSON."
64+ )
65+
66+ % {
67+ error:
68+ "Context not stored because it contains information not serializable to JSON."
69+ }
70+ end
71+
72+ put_change ( changeset , :context , validated_context )
6973 else
7074 changeset
7175 end
You can’t perform that action at this time.
0 commit comments