r4502: add an error reporting function