error handling for diag