-
Couldn't load subscription status.
- Fork 17
Open
Description
I built a telegram bot api proxy with cloudflare worker based on the open source project Telegram-API-Proxy, and when the proxy layer returned a message in non-json format, Jason.decode! crashed the whole program.
error throw in:
telegex/lib/telegex/caller/adapter.ex
Line 46 in cc8a77c
| data = Jason.decode!(json, keys: :atoms) |
** (Jason.DecodeError) unexpected byte at position 0: 0x3C ("<")
(jason 1.4.1) lib/jason.ex:92: Jason.decode!/2
(telegex 1.8.0) lib/telegex/caller/adapter.ex:46: Telegex.Caller.Adapter.struct_response/1
(telegex 1.8.0) lib/telegex/caller/adapter/httpoison.ex:25: Telegex.Caller.Adapter.HTTPoison.parse_response/1
(telegex 1.8.0) lib/telegex.ex:119: Telegex.get_me/0
(telegex 1.8.0) lib/telegex/instance.ex:48: Telegex.Instance.handle_call/3
(stdlib 5.2.3) gen_server.erl:1131: :gen_server.try_handle_call/4
(stdlib 5.2.3) gen_server.erl:1160: :gen_server.handle_msg/6
(stdlib 5.2.3) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
Last message (from RssGenericI18nBot.Telegram.TelegramPoller.Supervisor): :fetch_meI tried adding some debugging information to adapter.ex, and found that sometimes the proxy return [info] Would decode Telegram Response: error code: 520 file=lib/telegex/caller/adapter.ex line=46 application=telegex
@spec struct_response(String.t() | map) :: Response.t()
def struct_response(json) when is_binary(json) do
Logger.info("Would decode Telegram Response: #{json}")
data = Jason.decode!(json, keys: :atoms)
struct(Response, data)
endAre there any good ways to deal with it?
Metadata
Metadata
Assignees
Labels
No labels