Exceptions in interactive mode is easy to show as context/shell is alive, not so much with non-interactive. So one options would be to behave differently depending on a mode like printing stacktrace to teminal output on non-interactive. That way user gets useful errors immediately.