/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
 */

#import "ObjC.h"
#import <AGConnectDatabase/AGConnectCloudDB.h>

@implementation ObjC 

+ (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error {
    @try {
        tryBlock();
        return YES;
    }
    @catch (NSException *exception) {
        *error = [[NSError alloc] initWithDomain:exception.reason code:0 userInfo:exception.userInfo];
        return NO;
    }
}

+ (BOOL)deleteCloudDB:(AGConnectCloudDB*)agcConnectCloudDB zoneName:(NSString*)zoneName error:(__autoreleasing NSError **)error {
  
  [agcConnectCloudDB deleteCloudDBZone:zoneName error:error];
  if (*error != nil) {
    return NO;
  } else {
    return YES;
  }
  
}

+ (BOOL)closeCloudDB:(AGConnectCloudDB*)agcConnectCloudDB dbZone:(AGCCloudDBZone*)dbZone error:(__autoreleasing NSError **)error {
  
  [agcConnectCloudDB closeCloudDBZone:dbZone error:error];
  if (*error != nil) {
    return NO;
  } else {
    return YES;
  }
  
}


@end
