Add function for checking Error