Error output in txt file

Questions and answers on how to get the most out of FFAStrans
Larsdp
Posts: 14
Joined: Tue Dec 10, 2019 6:00 pm

Error output in txt file

Post by Larsdp »

Hi,

Newbie here. Trying to figure out a way to write out errors in a text file. Now i use the conditional node but how do i specify the exact error that the worflow fails on and pass that error out in the text file? My solution would be to only include one operation pr conditional like comparing framerate and if it fails it'll write out an txt with a framerate error. But if i had several errors it would only write out the first one and the node tree is going to be really long.

So checking a file for the right codec, framerate, bitrate etc and passing all the errors out in a txt file is what i want to do.

Thanks :-)
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Error output in txt file

Post by emcodem »

Hey Larsdp,
welcome to the forum and thank you for using ffastrans!

What you can do is to set your text file processor to execute "on error" instead of success (rightclick the input pin) - connect all your conditionals to this text proc.
The content of the text proc is just %s_error% in this case.

Lemme know if it works for you!
emcodem, wrapping since 2009 you got the rhyme?
Larsdp
Posts: 14
Joined: Tue Dec 10, 2019 6:00 pm

Re: Error output in txt file

Post by Larsdp »

Hi!
Thanks, it works but the error message is not that user friendly. I'm gettin "Conditional@Desktop: 1st evalutation of " = OP1a is " = OP1a"

Now i'm inputing a mp4 so my goal if possible is to write something out like, "wrong file container, wrong frame rate etc" like all erros in one txt file.
But maybe the point is that i have to write all the checks out into seperate nodes (one node for framerate etc)and then the workflow stops when a condition is not met?
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Error output in txt file

Post by emcodem »

Hm, i'd probably try to save nodes,, try this wofklow and let me know any questions :D

In the first populate proc, i do one check per line like this:

%i_width% = 720 ? "" : "Video Width error, actual width %i_width%"

What it does is on the left side of the ?, it checks some condition, e.g. %i_width% = 720
On the right side, we have two options divided by the :
Left option happens when the condition on the left is true, right happens when it's false. This way, the user variable %s_custom_error% would contain a corresponding error message or it stays empty.

After all the checks, i use a conditional to see if s_custom_error is empty.

emcodem_custom_error.json
(4.21 KiB) Downloaded 218 times
emcodem, wrapping since 2009 you got the rhyme?
Larsdp
Posts: 14
Joined: Tue Dec 10, 2019 6:00 pm

Re: Error output in txt file

Post by Larsdp »

Thanks! That's next level :-) I think i'll be quiet now for a while trying to look through it and learn.
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Error output in txt file

Post by emcodem »

Hehe working with variables makes you very mighty.
Besides the ? : syntax i explained above, one special thing the workflow does is to set %s_success% to %s_custom_error%. This is only to display the content of the variable %s_custom_error% on the job monitor's outcome column when the job has finished. Sure you'd want to replace the populate processor that happens "on error" after the conditional by your write text file node.
emcodem, wrapping since 2009 you got the rhyme?
Larsdp
Posts: 14
Joined: Tue Dec 10, 2019 6:00 pm

Re: Error output in txt file

Post by Larsdp »

Okay, so now i got to understand it a bit better. Question: the variable %s_custom_error% in the first node should there be two with the same name or should i create one pr condition test? It seems like a only get one error written out to the text file when using %s_custom_error% i'm testing a file with several errors so it should read multiple lines with framereate error and size error
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Error output in txt file

Post by emcodem »

Great, that was fast progress, congrats :D

Code: Select all

%i_width% = 720  ? "%s_custom_error%" : "Video Width error, actual width %i_width% | %s_custom_error%" 
You can just add %s_custom_error% whenever you set a new value to s_custom_error, i used an | symbol to separate the different errors above.
This way, the messages get appended. Of course we also need to set s_custom_error NOT to "" in case the contition succeds, but instead we set it to "%s_custom_error%", so it retains the current value

If you later need to format the list, you can just replace the | symbol by @CRLF.

The stuff with @CRLF is a little hard to explain, it is a global variable in the programming language that ffastrans is written in and stands for newline.

So, when all checks are done, in the populate proc at start, just do this as last thing:

%s_custom_error% = $replace("%s_custom_error%","|",@CRLF)

This way, %s_custom_error% will contain each single error separated by newline.

Sidenote:
Note the use of "" around any variable that is of type s_ . This is something you got to do whenever you insert s_ variables anywhere, they always need to be enclosed in "", e.g. "%s_source%". i_ or f_ variable types are numbers and therefore do not need to be enquoted, e.g. %i_width%
emcodem, wrapping since 2009 you got the rhyme?
Larsdp
Posts: 14
Joined: Tue Dec 10, 2019 6:00 pm

Re: Error output in txt file

Post by Larsdp »

Thanks, you got me again, need to sit down with a cup of coffee now. Thanks for helping me out!
Larsdp
Posts: 14
Joined: Tue Dec 10, 2019 6:00 pm

Re: Error output in txt file

Post by Larsdp »

Everything works perfect but i'm getting this in my text file:

Video height error, actual width 720
Video Width error, actual width 720
%s_custom_error%


So the %s_custom_error% varible is not being terminate or (not sure what is called). Do i remove that also by using the replace function?
Post Reply