Skip to content

Commit

Permalink
fix: Handle 400 and unknown error (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
pichoemr authored Mar 8, 2022
1 parent 59d1d5f commit aa7ab9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/lenra/lib/lenra/services/openfaas_services.ex
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ defmodule Lenra.OpenfaasServices do
)
when status_code not in [200, 202] do
case status_code do
400 ->
Logger.error(body)
{:error, :bad_request}

404 ->
Logger.error(body)
{:error, :ressource_not_found}
Expand All @@ -217,6 +221,10 @@ defmodule Lenra.OpenfaasServices do
504 ->
Logger.error(body)
{:error, :timeout}

_err ->
Logger.error(body)
{:error, :unknow_error}
end
end
end
1 change: 1 addition & 0 deletions apps/lenra_web/lib/lenra_web/views/error_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ defmodule LenraWeb.ErrorHelpers do
no_app_found: %{code: 21, message: "No application found for the current link."},
environement_not_build: %{code: 22, message: "This application was not yet build."},
widget_not_found: %{code: 23, message: "No Widget found in app manifest. This should not happen."},
bad_request: %{code: 400, message: "Server cannot understand or process the request due to a client-side error."},
error_404: %{code: 404, message: "Not Found."},
error_500: %{code: 500, message: "Internal server error."},
openfaas_not_reachable: %{code: 1000, message: "Openfaas is not accessible"},
Expand Down

0 comments on commit aa7ab9c

Please sign in to comment.