Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log errors on make_encoder() #14

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions lib/avrogen/schema/schema_registry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule Avrogen.Schema.SchemaRegistry do
"""

use GenServer
require Logger

@ets_name "all"

Expand Down Expand Up @@ -39,10 +40,25 @@ defmodule Avrogen.Schema.SchemaRegistry do
end)
|> Avrogen.Schema.topological_sort()
|> Noether.Either.map(fn schemas ->
json = Jason.encode!(schemas)
encoder = make_encoder(json)
decoder = make_decoder(json)
:ets.insert(__MODULE__, {@ets_name, json, encoder, decoder})
try do
json = Jason.encode!(schemas)
encoder = make_encoder(json)
decoder = make_decoder(json)
:ets.insert(__MODULE__, {@ets_name, json, encoder, decoder})
rescue
e ->
formatted_error = Exception.format(:error, e, __STACKTRACE__)

Logger.error(
"Error when attempting to make encoder/decoder: #{formatted_error}; schemas: #{inspect(schemas, limit: :infinity, pretty: true, printable_limit: :infinity)}",
%{
error: formatted_error,
schemas: schemas
}
)

reraise e, __STACKTRACE__
end
end)

{:ok, table}
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Avrogen.MixProject do
use Mix.Project

@version "0.7.2"
@version "0.7.3"
@source_url "https://github.com/primait/avrogen"

def project do
Expand Down
Loading