diff --git a/Source/ARTStatus.h b/Source/ARTStatus.h index 812c11863..38e7559e2 100644 --- a/Source/ARTStatus.h +++ b/Source/ARTStatus.h @@ -195,6 +195,7 @@ FOUNDATION_EXPORT NSString *const ARTAblyMessageNoMeansToRenewToken; @property (readonly) NSInteger statusCode; @property (nullable, readonly) NSString *href; @property (nullable, readonly) NSString *requestId; +@property (nullable, readonly) ARTErrorInfo *cause; + (ARTErrorInfo *)createWithCode:(NSInteger)code message:(NSString *)message; + (ARTErrorInfo *)createWithCode:(NSInteger)code status:(NSInteger)status message:(NSString *)message; diff --git a/Source/ARTStatus.m b/Source/ARTStatus.m index f06f35e2d..f32ae7b39 100644 --- a/Source/ARTStatus.m +++ b/Source/ARTStatus.m @@ -96,6 +96,14 @@ - (NSString *)reason { return reason; } +- (ARTErrorInfo *)cause { + NSError *underlyingError = self.userInfo[NSUnderlyingErrorKey]; + if (underlyingError == nil) { + return nil; + } + return [ARTErrorInfo createFromNSError:underlyingError]; +} + - (NSInteger)statusCode { return [self artStatusCode]; }