add km_onerr_print_exit function

prints and exits on failure
minor whitespace change