User bio
404 bio not found
Member since Feb 1, 2021
Pinned posts:
Replies:

I'm not sure there's any getting around having to check to the HTTP status entirely, but you could log an exception without throwing it, then throw a more user-friendly exception to your catch block to be returned. It would also get logged, but that's probably okay as long as whoever is looking at the system logs knows that will happen.

//Log this one
do ##class(%Exception.StatusException).CreateFromStatus($$$ERROR($$$GeneralError,HTTPSRequest.HttpResponse.StatusCode_" "_HTTPSRequest.HttpResponse.Data.Read())).Log()
//Throw this one
if HTTPSRequest.HttpResponse.StatusCode = 502{
    throw ##class(%Exception.StatusException).CreateFromStatus($$$ERROR($$$GeneralError,"The service is currently unavailable. Please call tech support or try again later."))
}

Then some elseif blocks for whatever other HTTP statuses you want to handle, then a final "else" at the bottom to throw something generic to catch anything else.

That at least gets the custom handling out of the catch block so it isn't processed for every exception.

Here's where you're hurting yourself:

    if $$$ISERR(tSC) {
        set tSC = $$$ERROR($$$GeneralError, "Error in sending request to the server")
        quit tSC
    }

tSC is already a status. You are changing it to a different status and forcing it to say "Error in sending request to the server." Replace that whole block of code with:

quit:$$$ISERR(tSC) tSC

That will quit if tSC is an error and give you the actual status that occurred. Once you have that, it'll hopefully be easier to troubleshoot this.

Open Exchange applications:
Certifications & Credly badges:
David has no Certifications & Credly badges yet.
Global Masters badges:
Followers:
Following:
David has not followed anybody yet.