safeResponseError method
Future<FetchFailure>
safeResponseError({
- required TypeError typeError,
- FetchFailure? errorServer,
- FetchFailure? errorWarning,
- FetchFailure? errorUnknow,
- bool? isShowError = true,
Implementation
Future<FetchFailure> safeResponseError(
{required TypeError typeError,
FetchFailure? errorServer,
FetchFailure? errorWarning,
FetchFailure? errorUnknow,
bool? isShowError = true}) async {
switch (typeError) {
case TypeError.ERROR_NO_DATA:
if (isShowError == true) {
return await FetchFailure.noData();
} else {
return await const FetchFailure.nothing();
}
case TypeError.ERROR_SERVER:
if (isShowError == true) {
return await errorServer ?? FetchFailure.noData();
} else {
return await const FetchFailure.nothing();
}
case TypeError.ERROR_WARNING:
if (isShowError == true) {
return await errorServer ?? FetchFailure.noData();
} else {
return await const FetchFailure.nothing();
}
case TypeError.ERROR_UNKNOWN:
if (isShowError == true) {
return await errorUnknow ?? FetchFailure.noData();
} else {
return await const FetchFailure.nothing();
}
default:
if (isShowError == true) {
return await const FetchFailure.noData();
} else {
return await const FetchFailure.nothing();
}
}
}