mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-09 13:07:37 +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
|
||||
try do
|
||||
{:ok, fun.()}
|
||||
catch
|
||||
:error, %Protocol.UndefinedError{protocol: Jason.Encoder, value: value} ->
|
||||
rescue
|
||||
error ->
|
||||
case error do
|
||||
%Protocol.UndefinedError{protocol: Jason.Encoder, value: value} ->
|
||||
{:error, "value #{inspect(value)} is not JSON-serializable, use another data type"}
|
||||
|
||||
:error, error ->
|
||||
error ->
|
||||
{:error, Exception.message(error)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp fastlane_encoder({:event, event, payload, %{ref: ref}}) do
|
||||
run_safely(fn ->
|
||||
|
|
Loading…
Add table
Reference in a new issue