add hooks for error/exception and improve non-interactive support