mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-13 09:25:36 +08:00
Refactoring error creation
This commit is contained in:
20
ios/CodePush/CodePushErrorUtils.m
Normal file
20
ios/CodePush/CodePushErrorUtils.m
Normal file
@@ -0,0 +1,20 @@
|
||||
#import "CodePush.h"
|
||||
|
||||
@implementation CodePushErrorUtils
|
||||
|
||||
static NSString *const CodePushErrorDomain = @"CodePushError";
|
||||
static const int CodePushErrorCode = -1;
|
||||
|
||||
+ (NSError *)errorWithMessage:(NSString *)errorMessage
|
||||
{
|
||||
return [NSError errorWithDomain:CodePushErrorDomain
|
||||
code:CodePushErrorCode
|
||||
userInfo:@{ NSLocalizedDescriptionKey: NSLocalizedString(errorMessage, nil) }];
|
||||
}
|
||||
|
||||
+ (BOOL)isCodePushError:(NSError *)err
|
||||
{
|
||||
return err != nil && [CodePushErrorDomain isEqualToString:err.domain];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user