NetTalk Central

Author Topic: NetWebService - detecting errors from JSON.append  (Read 4891 times)

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
NetWebService - detecting errors from JSON.append
« on: March 27, 2018, 11:58:59 PM »
Hi,

In the BuildResultFields routine, the JSONClass.append method is used to read data from a structure into the JSON object. When the structure is a table or view, there is no way however to detect whether errors occurred when loading the data with the .append method.

Is there something in JSONClass available to detect that the .append method had errors? If so, can the template be changed to accomodate for errors please?

Thanks
Thys

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: NetWebService - detecting errors from JSON.append
« Reply #1 on: April 09, 2018, 10:59:53 PM »
Hi Thys,

What sort of errors are you expecting or encountering?

There's no error trapping in jFiles itself - if it gets an error it breaks out the loop - but there is a records property which you can inspect after the append which tells how many records were added. Presumably you're expecting it to be > 0.

cheers
Bruce

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Re: NetWebService - detecting errors from JSON.append
« Reply #2 on: April 10, 2018, 12:00:58 AM »
Thanks Bruce.

Although I'm reading SQL data, I suppose that anything can happen when reading the VIEW - even with TPS. By using the RECORDS property won't be accurate - some results can return 0 records without the reading of data causing an error.

In a LOOP statement, there is actually only one error that is normal i.e. "Record Not Available" (error 33). Anything else can be regarded as abnormal and should be reported on. It will be helpful to have a property available in jFiles to capture such errors when .APPEND is run, so that an error can be reported on. I don't know how the internals of jFiles work, but adding such an error description property shouldn't have a negative effect on existing code?

Just on another topic, when checking for errors in a VIEW that is SQL-based, we use this statement as a standard way of determining the real reason for the error. Maybe you can use it as well?

    CHOOSE (ERRORCODE () = 90, FILEERROR (), ERROR ())

Thanks
Thys

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: NetWebService - detecting errors from JSON.append
« Reply #3 on: April 12, 2018, 12:43:34 AM »
In jFiles 1.61 I've added extra properties to store the file error code when it breaks the Loop View or Loop Table, if it's not the expected 'Record Not Available' error.

And in NetTalk 10.20 there's an embed point after the call to .add or .append which you can use to test this value.

cheers
Bruce

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Re: NetWebService - detecting errors from JSON.append
« Reply #4 on: April 12, 2018, 12:51:42 AM »
Thanks