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

Improve MongoosePush's logs on 4xx errors #1777

Merged
merged 1 commit into from
Apr 3, 2018
Merged
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
13 changes: 9 additions & 4 deletions src/mod_push_service_mongoosepush.erl
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,15 @@ http_notification(Host, Method, URL, ReqHeaders, Payload) ->
Pool = mongoose_http_client:get_pool(PoolName),
case mongoose_http_client:Method(Pool, URL, ReqHeaders, Payload) of
{ok, {BinStatusCode, Body}} ->
StatusCode = binary_to_integer(BinStatusCode),
case StatusCode >= 200 andalso StatusCode < 300 of
true -> ok;
false ->
case binary_to_integer(BinStatusCode) of
StatusCode when StatusCode >= 200 andalso StatusCode < 300 ->
ok;
StatusCode when StatusCode >= 400 andalso StatusCode < 500 ->
?ERROR_MSG("Unable to submit push notification. ErrorCode ~p, Payload ~p."
"Possible API mismatch - tried URL: ~p.",
[StatusCode, Payload, URL]),
{error, {invalid_status_code, StatusCode}};
StatusCode ->
?WARNING_MSG("Unable to submit push notification. ErrorCode ~p, Payload ~p",
[StatusCode, Body]),
{error, {invalid_status_code, StatusCode}}
Expand Down