Issue#85 - handling exemption when cache admin key not found
@@ -91,10 +91,18 @@ public class DefaultTenantUserApi implements TenantUserApi {
throw new TenantApiException(ErrorCode.EXTERNAL_KEY_LIMIT_EXCEEDED);
}
+ try {
// Not transactional, but there is a db constraint on that column
if (data.getApiKey() != null && getTenantByApiKey(data.getApiKey()) != null) {
throw new TenantApiException(ErrorCode.TENANT_ALREADY_EXISTS, data.getExternalKey());
}
+ } catch (final RuntimeException e) {
+ if (e.getCause() instanceof IllegalStateException) {
+ // could happen exemption, stating that the key is not found
+ } else {
+ throw e;
+ }
+ }
try {
tenantDao.create(new TenantModelDao(tenant), internalCallContextFactory.createInternalCallContextWithoutAccountRecordId(context));
