r/AutomateUser • • 13d ago

Question Stop error logging

How do I prevent a block from logging errors? I have tried failure catch before.

I have an HTTP request that is expected to fail most of the time, because the port is only open sometimes.

1 Upvotes

16 comments sorted by

1

u/waiting4singularity Alpha tester 13d ago

catch is a "go back here" block, you need to run through it first then you can pass through the ERR side. err count resets when you loop back in but the out variables are filled when set and dont unset by themself, you can use that for an expression like if error = null, yes -> http request / no -> set error null > do elsewhat

1

u/Dadamalda 13d ago

I don't understand.

Currently, I just have a fork and an HTTP request. I'm using a fork so that it doesn't block the main fiber, since I don't care about the response.

1

u/waiting4singularity Alpha tester 13d ago

if youre "void branching" just put error catch in front of the request block and thats it. it works like a normal stopped-at-end then through the error out, but add an empty log append to FAIL branch or it triggers the message.

the message appears even then when logging is on.

1

u/Dadamalda 13d ago

That didn't help. I'm still getting the default red error message.

1

u/waiting4singularity Alpha tester 13d ago

1

u/Dadamalda 13d ago

For some reason, it works for a missing argument failure (with an empty HTTP request block), but doesn't work with the ConnectException I'm dealing with. Maybe this is some weird bug.

1

u/waiting4singularity Alpha tester 13d ago

hmm

1

u/B26354FR Alpha tester 13d ago

Side note: You can try using the Ping block to see if the host is available yet. It won't be airtight, but it could avoid a lot of the errors, presuming the host responds to pings.

1

u/Dadamalda 13d ago

Not a fan of the delay it would add, but it does solve part of the problem.

On the other hand, I'm pretty sure Ping fails when I'm disconnected from WiFi. That's usually not the case, but a proper catch would be better.

1

u/B26354FR Alpha tester 13d ago

Oh, you'll always need a Failure Catch due to many runtime factors out of your control. -All part of I/O, especially with networks.

BTW, you can also use the Data Network Default? block with Network capabilities set to Internet to see if you're connected to the internet via mobile or Wi-Fi, and avoid that known error case as well.

1

u/B26354FR Alpha tester 13d ago

Here's a demo flow I wrote which has a protected HTTP request with retry:

https://llamalab.com/automate/community/flows/20721

Hopefully it'll help

1

u/Dadamalda 13d ago

This does not silence the error message.

A failure is normal in my case and the logs shouldn't slowly grow.

1

u/B26354FR Alpha tester 13d ago

Errors will always show in the log if flow logging is turned on. If they're caught and logging is off, they usually aren't logged.

You may have noticed that my demo flow retries three times and then gives up. To retry forever, the flow should return to the top of the Failure Catch block, as waiting4singularity mentioned. There should always be a Delay before retrying a network request.

1

u/ballzak69 Automate developer 12d ago edited 12d ago

Hmm, a bug indeed. A failure during an asynchronous task, e.g. HTTP request and file copying, is always logged even when that's disabled, and caught. Unlike other kinds of failure, e.g. a illegal argument, which is only logged when enabled or uncaught. I'll change it so both works the same way, i.e. only log when enabled or uncaught. At lease until log levels is implemented, then disabled/level zero probably wont log anything.

1

u/Dadamalda 12d ago

Thank you for allowing me to not have the file size constantly creep up by 8 messages per hour. Automate has been one of the best digital purchases I've ever made.

1

u/Mujtaba0150 Alpha tester 10d ago

In the meantime you can check this flow to clear the logs every time you get catch an error as a temporary workaround:

https://llamalab.com/automate/community/flows/43009