improved rewrite-error reporting