Permalink
Browse files

WHISTLE-788: try to handle unexpected values in sending admin emails

  • Loading branch information...
1 parent e4d8858 commit 2057e4239dd0100f6696d7fa2f57150a0bb92f1d @jamesaimonetti jamesaimonetti committed Feb 3, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 whistle_apps/src/whapps_util.erl
@@ -267,15 +267,16 @@ maybe_send_alert(Level, Format, Args, AccountId) ->
AlertLevel :: 0..8.
should_alert_system_admin(AlertLevel) ->
SystemLevel = whapps_config:get(<<"alerts">>, <<"system_admin_level">>, <<"debug">>),
+ ?LOG("system level: ~p", [SystemLevel]),
case alert_level_to_integer(SystemLevel) of
0 -> undefined;
- L when L =< AlertLevel ->
+ L when is_integer(L), L =< AlertLevel ->
case whapps_config:get(<<"alerts">>, <<"system_admin_email">>) of
- undefined -> undefined;
Email when is_binary(Email) ->
Email;
Emails when is_list(Emails) ->
- [wh_util:to_binary(E) || E <- Emails]
+ [wh_util:to_binary(E) || E <- Emails];
+ _ -> undefined
end;
_ -> undefined
end.
@@ -301,12 +302,11 @@ should_alert_account_admin(AlertLevel, AccountId) ->
0 -> undefined;
L when L =< AlertLevel ->
case wh_json:get_value([<<"alerts">>, <<"email">>], JObj) of
- undefined ->
- undefined;
Email when is_binary(Email) ->
Email;
Emails when is_list(Emails) ->
- [wh_util:to_binary(E) || E <- Emails]
+ [wh_util:to_binary(E) || E <- Emails];
+ _ -> undefined
end;
_ -> undefined
end;

0 comments on commit 2057e42

Please sign in to comment.