Put the debug call before the error handling

because in case it fails we can't retrieve the debug value