commit | author | age
|
3eceb5
|
1 |
// |
W |
2 |
// VKError.h |
|
3 |
// |
|
4 |
// Copyright (c) 2014 VK.com |
|
5 |
// |
|
6 |
// Permission is hereby granted, free of charge, to any person obtaining a copy of |
|
7 |
// this software and associated documentation files (the "Software"), to deal in |
|
8 |
// the Software without restriction, including without limitation the rights to |
|
9 |
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
|
10 |
// the Software, and to permit persons to whom the Software is furnished to do so, |
|
11 |
// subject to the following conditions: |
|
12 |
// |
|
13 |
// The above copyright notice and this permission notice shall be included in all |
|
14 |
// copies or substantial portions of the Software. |
|
15 |
// |
|
16 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17 |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|
18 |
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|
19 |
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|
20 |
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
21 |
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
22 |
|
|
23 |
#import <Foundation/Foundation.h> |
|
24 |
#import "VKObject.h" |
|
25 |
#import "VKApiConst.h" |
|
26 |
|
|
27 |
static int const VK_API_ERROR = -101; |
|
28 |
static int const VK_API_CANCELED = -102; |
|
29 |
static int const VK_API_REQUEST_NOT_PREPARED = -103; |
|
30 |
static int const VK_RESPONSE_STRING_PARSING_ERROR = -104; |
|
31 |
static int const VK_AUTHORIZE_CONTROLLER_CANCEL = -105; |
|
32 |
|
|
33 |
@class VKRequest; |
|
34 |
|
|
35 |
/** |
|
36 |
Class for presenting VK SDK and VK API errors |
|
37 |
*/ |
|
38 |
@interface VKError : VKObject |
|
39 |
/// Contains system HTTP error |
|
40 |
@property(nonatomic, strong) NSError *httpError; |
|
41 |
/// Describes API error |
|
42 |
@property(nonatomic, strong) VKError *apiError; |
|
43 |
/// Request which caused error |
|
44 |
@property(nonatomic, strong) VKRequest *request; |
|
45 |
|
|
46 |
/// May contains such errors:\n <b>HTTP status code</b> if HTTP error occured;\n <b>VK_API_ERROR</b> if API error occured;\n <b>VK_API_CANCELED</b> if request was canceled;\n <b>VK_API_REQUEST_NOT_PREPARED</b> if error occured while preparing request; |
|
47 |
@property(nonatomic, assign) NSInteger errorCode; |
|
48 |
/// API error message |
|
49 |
@property(nonatomic, strong) NSString *errorMessage; |
|
50 |
/// Reason for authorization fail |
|
51 |
@property(nonatomic, strong) NSString *errorReason; |
|
52 |
// Localized error text from server if there is one |
|
53 |
@property(nonatomic, strong) NSString *errorText; |
|
54 |
/// API parameters passed to request |
|
55 |
@property(nonatomic, strong) NSDictionary *requestParams; |
|
56 |
/// Captcha identifier for captcha-check |
|
57 |
@property(nonatomic, strong) NSString *captchaSid; |
|
58 |
/// Image for captcha-check |
|
59 |
@property(nonatomic, strong) NSString *captchaImg; |
|
60 |
/// Redirection address if validation check required |
|
61 |
@property(nonatomic, strong) NSString *redirectUri; |
|
62 |
|
|
63 |
@property(nonatomic, strong) id json; |
|
64 |
|
|
65 |
/** |
|
66 |
Generate new error with code |
|
67 |
@param errorCode positive if it's an HTTP error. Negative if it's API or SDK error |
|
68 |
*/ |
|
69 |
+ (instancetype)errorWithCode:(NSInteger)errorCode; |
|
70 |
|
|
71 |
/** |
|
72 |
Generate API error from JSON |
|
73 |
@param JSON Json description of VK API error |
|
74 |
*/ |
|
75 |
+ (instancetype)errorWithJson:(id)JSON; |
|
76 |
|
|
77 |
/** |
|
78 |
Generate API error from HTTP-query |
|
79 |
@param queryParams key-value parameters |
|
80 |
*/ |
|
81 |
+ (instancetype)errorWithQuery:(NSDictionary *)queryParams; |
|
82 |
|
|
83 |
/** |
|
84 |
Repeats failed captcha request with user entered answer to captcha |
|
85 |
@param userEnteredCode answer for captcha |
|
86 |
*/ |
|
87 |
- (void)answerCaptcha:(NSString *)userEnteredCode; |
|
88 |
@end |