The current implementation of ModelConverter.decodeJson() in Chapter 12 uses the following trick to catch API errors, assuming that response.isSuccessful is true
if (jsonMap['status'] != null) {
return response.copyWith(
body: Faileur(Exception(jsonMap)) as BodyType,
);
}
But actually, when we send invalid request, for example with wrong api_key, the response body is indeed as assumed jsonMap['status'] != null but with status_code: 401 and response.isSuccessful = false, thus the response is not intercepted by our ModelConverter but by the errorConverter which we don’t use, and also the implementation of _buildRecipeLoader doesn’t handle that case.