r/AutomateUser • u/Dadamalda • 16d 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
u/B26354FR Alpha tester 15d 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 15d 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 15d 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 15d 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 15d 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 15d 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 15d ago edited 15d 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 15d 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 12d ago
In the meantime you can check this flow to clear the logs every time you get catch an error as a temporary workaround:
1
u/waiting4singularity Alpha tester 16d 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