Page 1 of 1

Error handling

Posted: Mon May 31, 2021 12:40 pm
by f31n
Hi there,
I might just miss it out but is it possible to log an error of a command when scripting?

for example i just wrote an FTP upload script for my configs and would love to get the info of "/tool fetch [..]" why its not doing shit (in my case when running the command in the cli: status: failed failure: connection failed) which would be awesome to know so i don't need to look into that script further but can easily check the connection (a closed port in my case ^^)

Am i just missing out here something or is that simply not possible?

Re: Error handling

Posted: Mon May 31, 2021 6:49 pm
by rextended
on standard config you can read the error on system log

Have you simply read the manual?
https://wiki.mikrotik.com/wiki/Manual:Scripting

Re: Error handling

Posted: Sat Jun 05, 2021 10:02 pm
by f31n
what i am doing is uploading a backup via FTP with following command:
/tool fetch address=$ftpurl port=$ftpport src-path=$fname user=$ftpuser mode=ftp password=$ftppass dst-path="home/$fname" upload=yes
wherever I'm triggering that command no LOG entry is generated at all on error.
If triggered in the cli the error is displayed directly there (no route, login error, connection refused, etc)

but if i run that line in a script no error will be displayed anywhere, even tough i use the
do{
...
} on-error={
:log error "my error!"
}
syntax.
So I basically would like to catch the error I'm getting there and the system does realise that there is an error but i cannot address or log it ...

Re: Error handling

Posted: Sat Jun 05, 2021 10:59 pm
by Jotne
There are no solution for that in an MikroTik router.

Re: Error handling

Posted: Sun Jun 06, 2021 7:25 pm
by f31n
so here is no way of fetching an error thrown by a subroutine for advanced error handling / sending emails pushing notifications. thats a pity, i guess i should add that to the feature request list.

thanks for your help!