Skip to main content

I'm building a workflow that has error handling system in it. The idea is to send a message to the client about some specific error. To do that I've created a Custom Transformer that sends message.

 

It would be very handy to extract the Transformer Name and send it as a Error Code. In that way I can avoid typing an Error Code as a parameter value.

 

 

On the attached image you can see an example where ER000n are instances of the same Custom Transformer. I wonder is it possible to extract whatever was used as a Name of the transformer (ERR0006, ERR0007, etc.) form inside transformer? Extracted name will be a part of the Error Message that I'm sending to user.

 

 

Thanks

 

 

So what you want is the custom transformer instance name,  not the custom transformer name.

You can get that via one of two hacks.

 

 

Using a pythonCaller inside the customa transformer.

 

With a FeatureProcessor object,   self.factory_name  is {custom transformer instance name}_{PythonCaller instance name}.
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        feature.setAttribute("Name", self.factory_nameu:-13])
        self.pyoutput(feature)
    def close(self):
        pass

 

where the length of the slice depends on the name of the pythonCaller transformer

 

 

If you want to avoid python

Inside the custom transformer  you can use a ParameterFetcher set to {TransformerName}_WORKSPACE_NAME.

 

So if the custom transformer was called ERR then you would set it to ERR_WORKSPACE_NAME,  and it would return ERR006.  The reason it's a hack, is that the parameter name is considered invalid.  You will get the red wheel, but if you ignore it and run the workspace anyhow it works.

 

 

 


Fantastic :)

 

Thanks for help.

 

I prefer solution with the PythonCaller but the other method works also well.

 

 

The only drawback with the ParameterFetcher is that the transformer shows an error, however the workspace runs well with no errors and the results are good. Is it possible to get rid of the read error symbol on the transformer?

 

Thanks!!!

 

 


Fantastic :)

 

Thanks for help.

 

I prefer solution with the PythonCaller but the other method works also well.

 

 

The only drawback with the ParameterFetcher is that the transformer shows an error, however the workspace runs well with no errors and the results are good. Is it possible to get rid of the read error symbol on the transformer?

 

Thanks!!!

 

 

That's the reason I called it a hack and not a solution. There's nothing we can do to make the parameter valid. It would require a change to the software.

 

 

Maybe post an idea along the lines of "FME Macro Values should be valid parameter names in the ParameterFetcher"

Fantastic :)

 

Thanks for help.

 

I prefer solution with the PythonCaller but the other method works also well.

 

 

The only drawback with the ParameterFetcher is that the transformer shows an error, however the workspace runs well with no errors and the results are good. Is it possible to get rid of the read error symbol on the transformer?

 

Thanks!!!

 

 

Thanks, both hacks are great :)


Wow, great solutions. Would a VariableSetter/VariableRetrieve combination work as well?


Wow, great solutions. Would a VariableSetter/VariableRetrieve combination work as well?

Not that I am aware of? How would get the value to set in the VariableSetter?


Reply