safely throw error