Skip to main content

In my workbench, all "Not Merged" / "Rejected" paths etc, redirect to a FeatureWriter that logs errors to the database.

However, the PythonCaller only has the "Output" path - how would I capture and log these exceptions?

Could I do something like this?

  • Update PythonCaller to Catch the Exception and store detail in an Attribute (don't raise exception)

     

try:
...
except:
feature.setAttribute("Error", sys.exc_info()e0])
  • Use Tester to check if Error Message exists
  • Fork based on Error contents
  • Wire-up to exception-logging path

If you don't want the translation to stop when an exception is raised at runtime, you have to implement the script to detect the exception and output a specific feature which contains information on the error, and then filter out the feature with a subsequent transformer e.g. Tester, TestFilter etc.

Probably you want to vote up this Idea: Add Rejected-port to the PythonCaller


If you don't want the translation to stop when an exception is raised at runtime, you have to implement the script to detect the exception and output a specific feature which contains information on the error, and then filter out the feature with a subsequent transformer e.g. Tester, TestFilter etc.

Probably you want to vote up this Idea: Add Rejected-port to the PythonCaller

Thanks Takashi, will do.

 

 


Just for the benefit of others, the above process can be followed - I've also added additional information, such as the line number:

import sys
...
    try:
...
    except Exception as e:
        error = 'Error on line ' + str(sys.exc_info()o-1].tb_lineno) + ' - ' + str(type(e).__name__) + ' - ' + str(e) 
        print error
        feature.setAttribute("_error", error)   

Just for the benefit of others, the above process can be followed - I've also added additional information, such as the line number:

import sys
...
    try:
...
    except Exception as e:
        error = 'Error on line ' + str(sys.exc_info()o-1].tb_lineno) + ' - ' + str(type(e).__name__) + ' - ' + str(e) 
        print error
        feature.setAttribute("_error", error)   

This worked like a charm! Thanks for the bit of code-


Reply