mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-10 05:25:57 +08:00
Fix error recovery when serializing unknown structs in JS view payload
This commit is contained in:
parent
732db0ed45
commit
6853bbd9a1
1 changed files with 8 additions and 5 deletions
|
@ -105,14 +105,17 @@ defmodule LivebookWeb.JSViewChannel do
|
||||||
defp run_safely(fun) do
|
defp run_safely(fun) do
|
||||||
try do
|
try do
|
||||||
{:ok, fun.()}
|
{:ok, fun.()}
|
||||||
catch
|
rescue
|
||||||
:error, %Protocol.UndefinedError{protocol: Jason.Encoder, value: value} ->
|
error ->
|
||||||
|
case error do
|
||||||
|
%Protocol.UndefinedError{protocol: Jason.Encoder, value: value} ->
|
||||||
{:error, "value #{inspect(value)} is not JSON-serializable, use another data type"}
|
{:error, "value #{inspect(value)} is not JSON-serializable, use another data type"}
|
||||||
|
|
||||||
:error, error ->
|
error ->
|
||||||
{:error, Exception.message(error)}
|
{:error, Exception.message(error)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp fastlane_encoder({:event, event, payload, %{ref: ref}}) do
|
defp fastlane_encoder({:event, event, payload, %{ref: ref}}) do
|
||||||
run_safely(fn ->
|
run_safely(fn ->
|
||||||
|
|
Loading…
Add table
Reference in a new issue