Skip to content

Commit

Permalink
add validators to control plane operations
Browse files Browse the repository at this point in the history
  • Loading branch information
anitarua committed Jan 2, 2024
1 parent a206ff0 commit 9f598d3
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lib/src/cache_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,30 @@ class CacheClient implements ICacheClient {

@override
Future<CreateCacheResponse> createCache(String cacheName) {
// TODO: add validators
try {
validateCacheName(cacheName);
} catch (e) {
if (e is SdkException) {
return Future.error(CreateCacheError(e));
}
}
return _controlClient.createCache(cacheName);
}

@override
Future<DeleteCacheResponse> deleteCache(String cacheName) {
// TODO: add validators
try {
validateCacheName(cacheName);
} catch (e) {
if (e is SdkException) {
return Future.error(DeleteCacheError(e));
}
}
return _controlClient.deleteCache(cacheName);
}

@override
Future<ListCachesResponse> listCaches() {
// TODO: add validators
return _controlClient.listCaches();
}

Expand All @@ -79,7 +90,7 @@ class CacheClient implements ICacheClient {
validateCacheName(cacheName);
} catch (e) {
if (e is SdkException) {
return Future.error(GetError(e));
return Future.error(SetError(e));
}
}
return _dataClient.set(cacheName, key, value, ttl: ttl);
Expand All @@ -91,7 +102,7 @@ class CacheClient implements ICacheClient {
validateCacheName(cacheName);
} catch (e) {
if (e is SdkException) {
return Future.error(GetError(e));
return Future.error(DeleteError(e));
}
}
return _dataClient.delete(cacheName, key);
Expand Down

0 comments on commit 9f598d3

Please sign in to comment.