NetTalk Central

Author Topic: NetWebServiceMethod - error on delete doesn't give correct errorcode  (Read 4757 times)

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Hi,

Below is a portion of code in the DeleteRecord routine. You will notice that the first call p_web.AddServiceError uses ERRORCODE and ERROR to indicate the reason of the delete error. But it seems as if the errorcode  has been reset before this call, resulting in errorcode 0 to be returned here ("ERRORDESCRIPTION": "Error occured Deleting the record 0").

So it's important to catch the error before other calls are made. Also, if an error occurs using SQL then ERRORCODE only returns 90 (FileSystemError) which doesn't say much about the real error. You should use FILEERRORCODE to get the real reason. This type of statement helps a lot to get the correct description:

choose (errorcode () = 90, fileerror (), error ())

Thanks,
Thys

  do QueueToFile:RequiredAttribute
  If p_web.GetFile(RequiredAttribute,REQ:RequiredAttribute_PK) = 0
    idString = 'REQ:GUID = ' & REQ:GUID
    If p_web.sqlsync then p_web.SqlWait(p_web.SqlName).
    err = p_web.DeleteFile(RequiredAttribute)
    If p_web.sqlsync then p_web.SqlRelease(p_web.SqlName).
    if Err = 0
      p_web.AddServiceResult('Delete','RequiredAttribute',idString,'success')
    Else
      p_web.AddServiceError(Err,'dbRequiredAttribute', p_web.RecordIdentifier(RequiredAttribute), 'Error occured Deleting the record ' & errorcode() & ' '& error(), '')
    End
  Else
    p_web.AddServiceError(Error:RecordNotFound,'dbRequiredAttribute', p_web.RecordIdentifier(RequiredAttribute), 'Record not found when attempting to do a Delete', '')
  End

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
I've tweaked this for the 10.22 build to use the ErrorClass in ABC apps.

you can also use
p_web.Error(), p_web.ErrorCode(), p_web.FileError() and p_web.FileErrorCode() after calls to
p_web.OpenFile(), p_web.AddFile(), p_web.UpdateFile(), p_web.GetFile() and p_web.DeleteFile().

If you are using ABC file methods directly, like Access:Table.Insert and so on, then you can do a
p_web.SetErrors()
after the call, and then
p_web.Error(), p_web.ErrorCode(), p_web.FileError() and p_web.FileErrorCode()
will also return the various error values.

cheers
Bruce
« Last Edit: May 24, 2018, 12:25:11 AM by Bruce »

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
Re: NetWebServiceMethod - error on delete doesn't give correct errorcode
« Reply #2 on: August 31, 2018, 05:01:42 AM »
Hi Bruce.

I'm using 10.33 now. When trying to update a record, even with the Err returning 1, the values of p_web.Error (), p_web.ErrorCode () and p_web.FileErrorCode () are all blank or 0. When I replace the p_web.UpdateFile () statement with a simple PUT, not errors occur - so it looks like the .UpdateFile method may be doing something more than just a PUT.

Thys