improve exception handling

This commit is contained in:
Scott Pfeil 2022-03-01 17:53:58 -05:00
parent e89c10daae
commit 30d4c7730f

View File

@ -141,9 +141,11 @@
}
+ (id)initializerClassCheck:(nullable NSObject *)object classToVerify:(Class)classToVerify {
if (object) {
[self classIsInstanceTypeOfClass:object.class otherClass:classToVerify throwException:YES];
if (!object) { return nil; }
if (!object.class) {
@throw([NSException exceptionWithName:@"NoClass" reason:[NSString stringWithFormat:@"Object %@ is missing class %@", object, object.class] userInfo:nil]);
}
if (![self classIsInstanceTypeOfClass:object.class otherClass:classToVerify throwException:YES]) { return nil; }
return object;
}