class CustomNetworkError {
static String getErrorMessage(int code) {
switch (code) {
case 500:
return 'server issue';
case 401:
return 'token auth missing or incorrect or no such credentials any more';
case 404:
return 'missing resource';
case 403:
return 'authenticated but insufficient permission for action';
case 405:
return 'method not allowed — when you try to access a POST with a GET etc.';
case 400:
return 'bad request — for example if you don’t submit username and password fields to login';
default:
return 'unknown error';
}
}
}
Không có nhận xét nào:
Đăng nhận xét