added Errors.trap functionality