Skip to content

Commit

Permalink
Fix error message for rest request with 401 code
Browse files Browse the repository at this point in the history
So no more Error 401 displayed
  • Loading branch information
e-marchand committed Sep 5, 2024
1 parent fcd94b5 commit 4c4e0ca
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Project/Sources/Methods/Localize_server_response.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Else

$message:=Get localized string:C991("theWebServerIsNotReachable")

//……………………………………………………………………………
: ($in=401)

$message:=Get localized string:C991("unauthorizedAccess")

//……………………………………………………………………………
: ($in=403)

Expand Down
7 changes: 7 additions & 0 deletions Project/Sources/Methods/Rest.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,13 @@ WARNING: "localhost" may not find the server if the computer is connected to a n
End if
End if

If (($out.httpError=Null:C1517) && ($out.errors#Null:C1517) && ($out.errors.length>0))
$out.httpError:=String:C10($out.errors.first().message)
If (Length:C16($out.httpError)=0)
OB REMOVE:C1226($out; "httpError")
End if
End if

$out.headers:=New object:C1471

For ($i; 1; Size of array:C274($headerNames); 1)
Expand Down
5 changes: 4 additions & 1 deletion Project/Sources/Methods/project_BUILD.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,14 @@ If (Asserted:C1132($project#Null:C1517))
var $forError : Variant
$forError:=($rest.httpError=Null:C1517) ? $rest.code : $rest.httpError

var $httpError : Text
$httpError:=Localize_server_response($forError)

UI.postMessage(New object:C1471(\
"action"; "show"; \
"type"; "alert"; \
"title"; "theProductionServerIsNotAvailable"; \
"additional"; Localize_server_response($forError)\
"additional"; $httpError\
))

End if
Expand Down

0 comments on commit 4c4e0ca

Please sign in to comment.