Question
· 23 hr ago

Debugging %Net.HttpRequest

I think I found my solution but I'm trying to understand better why it works. Forgive me as my descriptions here may be scattered but I'm trying to piece the puzzle together.

Scenario: I've found there are times when I make a request using a %Net.HttpRequest object and as I'm debugging and stepping through via the debugger in VSCode, if I try to access an object in the 'variables' menu, sometimes when I click that little expand button it will just spin and never load what's in the object to the viewer. This recently manifested itself in a process where we are calling a bunch of APIs and it got stuck.  In the CLI if we run it and see it's stuck we just CTRL+C or X and it DOESN'T break the process rather it's almost like it was a GO command on a break point and the process continues.

Now that I think of it, this behavior sometimes shows up when I'm trying to access a dynamic object.  E.g. let's say I'm expected to set personId=dynArray.%Get(0).personId, but that there's no object with a personId at index 0, I will get this kind of error. I find often the safter thing to do is if $ISOBJECT(dynArray.%Get(0),dnyArray%Get(0).%Exists("personId"), then set personId= . . . 

I THINK the solution in my %Net.HttpRequest is to check the status before trying to process the response. E.g. s status=httpReqObj.Get() if $$$ISERR(status) throw . . . Before I was simply doing a d httpReqObj.Get() and then trying to process the response in the object without fist checking if it was an error. 

This is ALL in a try/catch block, so what is happening that trying to access these object and properties that may be errors or bad data that causes the process to spin rather than throw the exception to the catch block?

Please, throw some questions at me if you need more info . . . I know I haven't provided the clearest steps to reproduce and my hope is that people have come across this kind of behavior.  

To summarize though, it seems I can avoid by checking the status after calling the HTTP request method when dealing with %Net.HttpRequest objects. When it come to dynamic objects and accessing properties there, it seems tedious to call $ISOBJECT and %Exists() on every object and property when trying to access objects but it does seem to save me lots of failed error catches.

What are your thoughts?

Product version: IRIS 2023.1
$ZV: IRIS for UNIX (Ubuntu Server LTS for ARM64 Containers) 2023.1.5 (Build 697U) Thu Oct 3 2024 14:36:32 EDT
Discussion (0)1
Log in or sign up to continue