From 65c9c072972779927afd8024a3d97535bad6a80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Wed, 7 Apr 2021 17:24:21 +0200 Subject: [PATCH] Wrap Odoo auth in try block --- lib/recycledcloud/odoo.ex | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/recycledcloud/odoo.ex b/lib/recycledcloud/odoo.ex index cb17b06..ba4d2bf 100644 --- a/lib/recycledcloud/odoo.ex +++ b/lib/recycledcloud/odoo.ex @@ -32,12 +32,15 @@ defmodule RecycledCloud.Odoo do nil ] - auth_response = %XMLRPC.MethodCall{method_name: "authenticate", params: auth_params} - |> post!(@common_endpoint) - case auth_response do - {:ok, false} -> {:error, "Could not authenticate against Odoo."} - {:ok, uid} -> {:ok, uid} - {:error, err} -> {:error, err} + try do + auth_response = %XMLRPC.MethodCall{method_name: "authenticate", params: auth_params} + |> post!(@common_endpoint) + case auth_response do + {:ok, false} -> {:error, "Could not authenticate against Odoo."} + {:ok, uid} -> {:ok, uid} + {:error, err} -> {:error, err} + end + rescue e -> {:error, e} end end