Extract api error in a separate file