IMatch.fileInfo

Started by peterverm, October 22, 2017, 10:44:45 AM

Previous topic - Next topic

peterverm

Dear,

i need help on IMatch.fileInfo.  It used to work, but not any more.  I don't understand what i do wrong.

I call IMatch.fileInfo to check whether a file exists or not. 
If it exists, the function(response) part is executed, no problems.
If it does not exist,
    i have a GET http error in the console .  You can see this in the print screen, the "2" in red.
    and the function(error) part is executed.  You can see this in the print screen, the "1" in red. JSON.stringify(error,null,2)) is executed, the error is written in the window on the left.

The script should now continue processing the next file.   But it doesn't.  It stops.  Why ?  Can you advise ?

The JAVA script is in attachment too, as txt file.

Regards,

Peter


Mario

#1
The endpoint returns HTTP status code 404 (file not found) when the file does not exist.
This is how the response looks on my system:


   {
  "readyState": 4,
  "responseText": "{\r\n \"error\":{\r\n  \"code\":2,\r\n  \"message\":\"File does not exist\"\r\n }\r\n}",
  "responseJSON": {
    "error": {
      "code": 2,
      "message": "File does not exist"
    }
  },
  "status": 404,
  "statusText": "Not Found"
}


How does the response looks on your system?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

peterverm

Mario,

exactly the same.  see the print screen.

The problem is that after the error handling, the script stops.  I don't know why.  It there an instruction to force it to continue ? to ignore the error ?

Thanks,

Peter

Mario

#3
What do you mean by "script stops"? Is an exception raised you don't handle? Anything in the console?`
Please understand that I'm unable to remote debug your scripts, sorry.

Run you script in a web browser, open the debugger tools and set a break point in your error handler.
If the script aborts for some reason (unhandled exception, invalid access to data) the debugger will tell you what that problem is.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

peterverm

You are right and i should use my 'gray matter' more.  It's a bug in my program logic.  I found it, it's solved.

Thanks,

Peter

Mario

Great. Let us know what the problem was below, in case another user finds this thread in the future and wonders how to solve his/her problem...
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

peterverm

With pleasure.

First, the script didn't work any more because the response of fileInfo(fileName) had changed.

Previously, i tested in function(response) { if (response.result == 'ok') { abc... } else { xyz... }; vwz... }
Notice that there was code vwz... that was always executed, regardless of response.result == 'ok' or not.

But "result" is no longer a property of "response" any more.

I adapted my code to : function(response) { abc... vwz... }, function(error) { xyz... }
Notice that i forgot to add the vwz... code in the function(error).  So of course it didn't work.

Now i changed my code to : function(response) { abc... vwz... }, function(error) { xyz... vwz... } and it works just fine (again).

I hope this helps someone.

Regards,

Peter