Something I've noticed is that when there is an error in our script (regardless of the programming language), it often takes longer to "execute" and then output the error, compared to its execution time when there are no errors in our script. 
Why does this happen? Shouldn't outputting an error take less time because the script is not being fully run? Or does the computer still attempt to fully run the script regardless of whether there is an error or not?
For example, I have a Python script that takes approximately 10 seconds to run if there are no errors. When there is an error, however, it takes an average of 15 seconds. I've noticed something similar in NodeJS, so I'm just assuming that this is the case for many programming languages? Apologies if this is a bad question - I'm relatively new to programming and still lack some fundamental understandings.
The program doesn't attempt to run the script fully in case of an error, the execution is interrupted at the point where an error happens. This is by default but you can always set up your own exception handlers in your scripts which will execute some code.
Anyway, raising and handling (logging) exceptions also requires some code execution (internal code of the programming language) thus this also takes some time.
It's hard to tell why your script execution takes longer in case of an error without looking at your script though, I personally never noticed such differences in general but maybe I just didn't pay attention...
Why do errors take longer than the script itself?