Script Success and failure
A valid script execution follows these rules:
- It runs from left to right.
- It continues until one of two things happens, either the script reaches its end naturally or an operation within the script signals a failure.
- If the script completes without any early failure, the success or failure of the script depends solely on the top item of the stack.
In essence, a script is considered successful if it runs to completion and leaves a single "true" or any non-zero value on top of the stack.
Any other outcome - early termination, an empty stack, or a "false" value on top - results in the script being considered invalid or failed.
Other types of errors
If you'd like to learn more about these type of errors you can check the script_error.cpp file from bitcoin core source code