Skip to main content
Solved

How to ignore errors in RCaller

  • October 25, 2024
  • 5 replies
  • 70 views

mr_fme
Enthusiast
Forum|alt.badge.img+8

Hi,

I have one script in R running in RCaller, but the RCaller show some messages like erros but no erros, my script run properly.

 

I would like to ignore these messages and generate one feature for the next transformer. How can I do this?

 

 

Thank´s

Best answer by hkingsbury

As i mentioned, i’m no R expert, but the above looks fine.

It’s quiet difficult to debug without being able to see the full log and script.

Might be best to open a support ticket with your reseller where you can share that level of information with them.

View original
Did this help you find an answer to your question?

5 replies

hkingsbury
Celebrity
Forum|alt.badge.img+53
  • Celebrity
  • October 28, 2024

Depending on how the RCaller is ‘failing’ I can think of two approaches (FYI i’ve never used R).

  1. If the RCaller is not outputing a feature because it doesn’t return a feature to trigger the rest of the workspace, you could put a NoFeatureTester after it and this will create a feature if none are recieved.
  2. If the RCaller is failing and is therefore causing the workspace to fail, you could look to use the tryCatch() function - https://stackoverflow.com/questions/12193779/how-to-use-the-trycatch-function

mr_fme
Enthusiast
Forum|alt.badge.img+8
  • Author
  • Enthusiast
  • October 29, 2024

Hi @hkingsbury 

 

I tried your options, but unsuccess.

 

No FeatureTester no show features after erro in RCaller.

Try Catch too...no work properly. Shows errors in RCaller.

 

Thank you

 

 


hkingsbury
Celebrity
Forum|alt.badge.img+53
  • Celebrity
  • October 29, 2024

Can you share how you’ve implemented the tryCatch() in you code?

The purpose of try-catch functions are to gracefully catch errors allowing processes to properly manage them with out failing


mr_fme
Enthusiast
Forum|alt.badge.img+8
  • Author
  • Enthusiast
  • November 1, 2024

@hkingsbury,

 

Unfortunately I can´t send the code, but my implemantation is like below:

 

 tryCatch(
        {
            # Just to highlight: if you want to use more than one
            # R expression in the "try" part then you'll have to
            # use curly brackets.
            # 'tryCatch()' will return the last evaluated expression
            # in case the "try" part was completed successfully

            message("This is the 'try' part")

            suppressWarnings(readLines(url))
            # The return value of `readLines()` is the actual value
            # that will be returned in case there is no condition
            # (e.g. warning or error).
        },
        error = function(cond) {
            message(paste("URL does not seem to exist:", url))
            message("Here's the original error message:")
            message(conditionMessage(cond))
            # Choose a return value in case of error
            NA
        },
        warning = function(cond) {
            message(paste("URL caused a warning:", url))
            message("Here's the original warning message:")
            message(conditionMessage(cond))
            # Choose a return value in case of warning
            NULL
        },
        finally = {
            # NOTE:
            # Here goes everything that should be executed at the end,
            # regardless of success or error.
            # If you want more than one expression to be executed, then you
            # need to wrap them in curly brackets ({...}); otherwise you could
            # just have written 'finally = <expression>' 
            message(paste("Processed URL:", url))
            message("Some other message at the end")
        }
    )
}

hkingsbury
Celebrity
Forum|alt.badge.img+53
  • Celebrity
  • Best Answer
  • November 3, 2024

As i mentioned, i’m no R expert, but the above looks fine.

It’s quiet difficult to debug without being able to see the full log and script.

Might be best to open a support ticket with your reseller where you can share that level of information with them.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings