Make error handling code consistent with expected thread first