AnsweredAssumed Answered

Error Handling

Question asked by jurgmay on Dec 8, 2015
Latest reply on Dec 8, 2015 by jurgmay

Hi all,

 

I'm looking to gather any thoughts or opinions that you guys may have on how best to handle errors in scripts.

 

As an example, I have a script which polls an eCommerce server every few minutes to see if any orders have been placed. Orders are downloaded as XML data. I then parse the XML and create the orders and associated line items in FileMaker and download any files which may be linked to the line items (there's a field with a URL which points to the file).

 

The outline of my main script (using pseudo code) looks like this -

 

Perform Script ( "Pull Pending Orders From Server" )

Set Variable ( $xmlData ; Get ( ScriptResult )

If ( not IsEmpty ( $xmlData ) )

-- Perform Script ( "Create Orders" )

-- Perform Script ( "Create Line Items" )

-- Perform Script ( "Update Revenue Values" )

End If

 

Each of the three scripts 'Pull Pending Orders From Server', 'Create Orders', 'Create Line Items' could potentially create errors that I would need to handle. For example, if there is no internet connection then 'Pull Pending Orders From Server' would fail; if malformed or corrupt XML is received from the server then 'Create Orders' could fail; if any files associated with the Line Items fail to download then the 'Create Line Items' script would fail.

 

I'm just not sure WHERE the error handling should take place.

 

Is it best practice for the error to be raised in the relevant script and then passed back using 'Exit Script' and have each script in the Call Stack pass that error back to the main script and then handle it from there?

 

Also, I'm thinking that it would be a good idea to create an 'Error Message' table that associates error text with an error number so that I can display a relevant message to the user based on the error that was raised. Is that a good idea?

 

I'd appreciate any comments on how error handling in general should be undertaken.

 

Thanks as always,

 

Juerg

Outcomes