setItem method
Persists WriteOperation.item.
Implementation
@override
Future<WriteResult<T>> setItem(WriteOperation<T> operation) async {
if (setItemHandler == null) {
throw UnimplementedError();
}
late final T? obj;
try {
obj = await setItemHandler!.call(operation);
} on Exception catch (e) {
_log.severe(e);
return WriteFailure<T>(
FailureReason.serverError,
'Failed to save ${operation.item}',
);
}
if (obj == null && bindings.getId(operation.item) == null) {
_log.warning(
'Saved new $T but no object was returned; therefore we do not know '
'its Id',
);
}
return WriteSuccess<T>(obj ?? operation.item, details: operation.details);
}