upsert<_Model extends OfflineFirstWithRestModel> method
Future<_Model>
upsert<_Model extends OfflineFirstWithRestModel>(
- _Model instance, {
- OfflineFirstUpsertPolicy policy = OfflineFirstUpsertPolicy.optimisticLocal,
- Query? query,
- bool throwOnReattemptStatusCodes = false,
throwOnReattemptStatusCodes
- when true
, the repository will throw an
OfflineFirstException
for responses that include a code within reattemptForStatusCodes
.
Defaults false
.
Implementation
@override
Future<_Model> upsert<_Model extends OfflineFirstWithRestModel>(
_Model instance, {
OfflineFirstUpsertPolicy policy = OfflineFirstUpsertPolicy.optimisticLocal,
Query? query,
bool throwOnReattemptStatusCodes = false,
}) async {
try {
return await super.upsert<_Model>(instance, policy: policy, query: query);
} on RestException catch (e) {
logger.warning('#upsert rest failure: $e');
if (_ignoreTunnelException(e)) {
return instance;
}
// since we know we'll reattempt this request, an exception does not need to be reported
if (reattemptForStatusCodes.contains(e.response.statusCode) && !throwOnReattemptStatusCodes) {
return instance;
}
throw OfflineFirstException(e);
}
}