I believe this is on-par feature-wise with what’s in master, but it’s incomplete as far as error codes go.
As suggested by @gmaxwell and @sipa, remove logging in favor of well-defined error codes for the script interpreter. This is necessary for the consensus lib, in order to remove the last bits of application state (along with #5162).
Every possible exit path of EvalScript() sets a ScriptError to indicate if/why it failed. I quickly enumerated the cases that had existing log messages, but the rest still need to be filled in. For every undefined failure, SCRIPT_UNKNOWN_ERROR is returned. It’s important to keep in mind that these values will be part of the lib’s stable external API, so it’s necessary to put some thought into how they’re defined.
Before continuing, I’d like to know that others are comfortable with this approach.