nullIfNotFound<T> function
Future<T?>
nullIfNotFound<T>(
- Future<
T?> fetchFunction(- RequestConfig requestConfig
- RequestConfig? requestConfig,
Implementation
Future<T?> nullIfNotFound<T>(
Future<T?> Function(RequestConfig requestConfig) fetchFunction,
{RequestConfig? requestConfig}) async {
try {
return await fetchFunction(
requestConfig ?? RequestConfig(ignoreErrors: true));
} catch (e) {
if (e is ThingsboardError &&
e.errorCode == ThingsBoardErrorCode.itemNotFound) {
return null;
} else {
rethrow;
}
}
}