callback function closed now properly record the reason and code of the error