//
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2017 by PDFTron Systems Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------
#import "PTPDFNet+catchException.h"


@implementation PTPDFNet (catchException)

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

        return NO;
    }
}

@end
