|
8 | 8 |
|
9 | 9 | #import <Foundation/Foundation.h>
|
10 | 10 |
|
| 11 | +/** |
| 12 | + * 中途取消的状态码 |
| 13 | + */ |
11 | 14 | extern const int kQNRequestCancelled;
|
| 15 | + |
| 16 | +/** |
| 17 | + * 网络错误状态码 |
| 18 | + */ |
12 | 19 | extern const int kQNNetworkError;
|
| 20 | + |
| 21 | +/** |
| 22 | + * 错误参数状态码 |
| 23 | + */ |
13 | 24 | extern const int kQNInvalidArgument;
|
| 25 | + |
| 26 | +/** |
| 27 | + * 读取文件错误状态码 |
| 28 | + */ |
14 | 29 | extern const int kQNFileError;
|
15 | 30 |
|
| 31 | +/** |
| 32 | + * 上传完成后返回的状态信息 |
| 33 | + */ |
16 | 34 | @interface QNResponseInfo : NSObject
|
17 | 35 |
|
| 36 | +/** |
| 37 | + * 状态码 |
| 38 | + */ |
18 | 39 | @property (readonly) int statusCode;
|
| 40 | + |
| 41 | +/** |
| 42 | + * 七牛服务器生成的请求ID,用来跟踪请求信息,如果使用过程中出现问题,请反馈此ID |
| 43 | + */ |
19 | 44 | @property (nonatomic, copy, readonly) NSString *reqId;
|
| 45 | + |
| 46 | +/** |
| 47 | + * 七牛服务器内部跟踪记录 |
| 48 | + */ |
20 | 49 | @property (nonatomic, copy, readonly) NSString *xlog;
|
| 50 | + |
| 51 | +/** |
| 52 | + * 错误信息,出错时请反馈此记录 |
| 53 | + */ |
21 | 54 | @property (nonatomic, copy, readonly) NSError *error;
|
| 55 | + |
| 56 | +/** |
| 57 | + * 是否取消 |
| 58 | + */ |
22 | 59 | @property (nonatomic, readonly, getter = isCancelled) BOOL canceled;
|
| 60 | + |
| 61 | +/** |
| 62 | + * 成功的请求 |
| 63 | + */ |
23 | 64 | @property (nonatomic, readonly, getter = isOK) BOOL ok;
|
| 65 | + |
| 66 | +/** |
| 67 | + * 是否网络错误 |
| 68 | + */ |
24 | 69 | @property (nonatomic, readonly, getter = isConnectionBroken) BOOL broken;
|
| 70 | + |
| 71 | +/** |
| 72 | + * 是否需要重试,内部使用 |
| 73 | + */ |
25 | 74 | @property (nonatomic, readonly) BOOL couldRetry;
|
26 | 75 |
|
| 76 | +/** |
| 77 | + * 工厂函数,内部使用 |
| 78 | + * |
| 79 | + * @return 取消的实例 |
| 80 | + */ |
27 | 81 | + (instancetype)cancel;
|
28 | 82 |
|
| 83 | +/** |
| 84 | + * 工厂函数,内部使用 |
| 85 | + * |
| 86 | + * @param desc 错误参数描述 |
| 87 | + * |
| 88 | + * @return 错误参数实例 |
| 89 | + */ |
29 | 90 | + (instancetype)responseInfoWithInvalidArgument:(NSString *)desc;
|
30 | 91 |
|
| 92 | +/** |
| 93 | + * 工厂函数,内部使用 |
| 94 | + * |
| 95 | + * @param error 错误信息 |
| 96 | + * |
| 97 | + * @return 网络错误实例 |
| 98 | + */ |
31 | 99 | + (instancetype)responseInfoWithNetError:(NSError *)error;
|
32 | 100 |
|
| 101 | +/** |
| 102 | + * 工厂函数,内部使用 |
| 103 | + * |
| 104 | + * @param error 错误信息 |
| 105 | + * |
| 106 | + * @return 文件错误实例 |
| 107 | + */ |
33 | 108 | + (instancetype)responseInfoWithFileError:(NSError *)error;
|
34 | 109 |
|
| 110 | +/** |
| 111 | + * 构造函数 |
| 112 | + * |
| 113 | + * @param status 状态码 |
| 114 | + * @param reqId 七牛服务器请求id |
| 115 | + * @param xlog 七牛服务器记录 |
| 116 | + * @param body 服务器返回内容 |
| 117 | + * |
| 118 | + * @return 实例 |
| 119 | + */ |
35 | 120 | - (instancetype)init:(int)status
|
36 | 121 | withReqId:(NSString *)reqId
|
37 | 122 | withXLog:(NSString *)xlog
|
|
0 commit comments