DBRequestError
Objective-C
@interface DBRequestError : NSObject
Swift
class DBRequestError : NSObject
Base class for generic network request error (as opposed to route-specific error).
This class is represented almost like a Stone “Union” object. As one object, it can represent a number of error
“states” (see all of the values of DBRequestErrorType
). To handle each error type, call each of the
is<TAG_STATE>
methods until you determine the current tag state, then call the corresponding as<TAG_STATE>
method to return an instance of the appropriate error type.
For example:
if ([dbxError isHTTPError]) { DBHttpError *httpError = [dbxError asHttpError]; } else if ([dbxError isBadInputError]) { ……..
-
Current state of the
DBRequestError
object type.Declaration
Objective-C
@property (nonatomic, readonly) DBRequestErrorTag tag;
Swift
var tag: DBRequestErrorTag { get }
-
The Dropbox request id of the network call. This is useful to Dropbox for debugging issues with Dropbox’s SDKs and API. Please include the value of this field when submitting technical support inquiries to Dropbox.
Declaration
Objective-C
@property (nonatomic, copy, readonly, nullable) NSString *requestId;
Swift
var requestId: String? { get }
-
The HTTP response status code of the request.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSNumber *statusCode;
Swift
var statusCode: NSNumber? { get }
-
A string representation of the error body received in the reponse. If for a route-specific error, this field will be the value of the “error_summary” key.
Declaration
Objective-C
@property (nonatomic, copy, readonly, nullable) NSString *errorContent;
Swift
var errorContent: String? { get }
-
An object containing a localized human-readable error message that is optionally returned from some API endpoints.
Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) DBLocalizedUserMessage *userMessage;
Swift
var userMessage: DBLocalizedUserMessage? { get }
-
The structured object returned by the Dropbox API in the event of a 401 auth error.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) DBAUTHAuthError *structuredAuthError;
Swift
var structuredAuthError: DBAUTHAuthError? { get }
-
The structured object returned by the Dropbox API in the event of a 403 access error.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) DBAUTHAccessError *structuredAccessError;
Swift
var structuredAccessError: DBAUTHAccessError? { get }
-
The structured object returned by the Dropbox API in the event of a 422 path root error.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) DBCOMMONPathRootError *structuredPathRootError;
Swift
var structuredPathRootError: DBCOMMONPathRootError? { get }
-
The structured object returned by the Dropbox API in the event of a 429 rate-limit error.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) DBAUTHRateLimitError *structuredRateLimitError;
Swift
var structuredRateLimitError: DBAUTHRateLimitError? { get }
-
The number of seconds to wait before making any additional requests in the event of a rate-limit error.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSNumber *backoff;
Swift
var backoff: NSNumber? { get }
-
The client-side
NSError
object returned from the failed response.Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSError *nsError;
Swift
var nsError: Error? { get }
-
DBRequestError
convenience constructor.Initializes the
DBRequestError
object with all the required state for representing a generic HTTP error.Declaration
Objective-C
- (nonnull instancetype)initAsHttpError:(nullable NSString *)requestId statusCode:(nullable NSNumber *)statusCode errorContent:(nullable NSString *)errorContent userMessage: (nullable DBLocalizedUserMessage *)userMessage;
Swift
init(asHttpError requestId: String?, statusCode: NSNumber?, errorContent: String?, userMessage: DBLocalizedUserMessage?)
Parameters
requestId
The Dropbox request id of the network call. This is useful to Dropbox for debugging issues with Dropbox’s SDKs and API.
statusCode
The HTTP response status code of the request.
errorContent
A string representation of the error body received in the reponse. If for a route-specific error, this field will be the value of the “error_summary” key.
userMessage
An error message object that is optionally returned from some API endpoints.
Return Value
An initialized
DBRequestError
instance with HTTP error state. -
DBRequestError convenience constructor.
Initializes the
DBRequestError
with all the required state for representing a Bad Input error.Declaration
Objective-C
- (nonnull instancetype)initAsBadInputError:(nullable NSString *)requestId statusCode:(nullable NSNumber *)statusCode errorContent:(nullable NSString *)errorContent userMessage:(nullable DBLocalizedUserMessage *) userMessage;
Swift
init(asBadInputError requestId: String?, statusCode: NSNumber?, errorContent: String?, userMessage: DBLocalizedUserMessage?)
Parameters
requestId
The Dropbox request id of the network call. This is useful to Dropbox for debugging issues with Dropbox’s SDKs and API.
statusCode
The HTTP response status code of the request.
errorContent
A string representation of the error body received in the reponse. If for a route-specific error, this field will be the value of the “error_summary” key.
userMessage
An error message object that is optionally returned from some API endpoints.
Return Value
An initialized
DBRequestError
instance with Bad Input error state. -
DBRequestError convenience constructor.
Initializes the
DBRequestError
with all the required state for representing an Auth error.Declaration
Objective-C
- (nonnull instancetype) initAsAuthError:(nullable NSString *)requestId statusCode:(nullable NSNumber *)statusCode errorContent:(nullable NSString *)errorContent userMessage:(nullable DBLocalizedUserMessage *)userMessage structuredAuthError:(nonnull DBAUTHAuthError *)structuredAuthError;
Swift
init(asAuthError requestId: String?, statusCode: NSNumber?, errorContent: String?, userMessage: DBLocalizedUserMessage?, structuredAuthError: DBAUTHAuthError)
Parameters
requestId
The Dropbox request id of the network call. This is useful to Dropbox for debugging issues with Dropbox’s SDKs and API.
statusCode
The HTTP response status code of the request.
errorContent
A string representation of the error body received in the reponse. If for a route-specific error, this field will be the value of the “error_summary” key.
userMessage
An error message object that is optionally returned from some API endpoints.
structuredAuthError
The structured object returned by the Dropbox API in the event of a 401 auth error.
Return Value
An initialized
DBRequestError
instance with Auth error state. -
DBRequestError convenience constructor.
Initializes the
DBRequestError
with all the required state for representing an Access error.Declaration
Objective-C
- (nonnull instancetype) initAsAccessError:(nullable NSString *)requestId statusCode:(nullable NSNumber *)statusCode errorContent:(nullable NSString *)errorContent userMessage:(nullable DBLocalizedUserMessage *)userMessage structuredAccessError:(nonnull DBAUTHAccessError *)structuredAccessError;
Swift
init(asAccessError requestId: String?, statusCode: NSNumber?, errorContent: String?, userMessage: DBLocalizedUserMessage?, structuredAccessError: DBAUTHAccessError)
Parameters
requestId
The Dropbox request id of the network call. This is useful to Dropbox for debugging issues with Dropbox’s SDKs and API.
statusCode
The HTTP response status code of the request.
errorContent
A string representation of the error body received in the reponse. If for a route-specific error, this field will be the value of the “error_summary” key.
userMessage
An error message object that is optionally returned from some API endpoints.
structuredAccessError
The structured object returned by the Dropbox API in the event of a 403 access error.
Return Value
An initialized
DBRequestError
instance with Auth error state. -
DBRequestError convenience constructor.
Initializes the
DBRequestError
with all the required state for representing a Path Root error.Declaration
Objective-C
- (nonnull instancetype) initAsPathRootError:(nullable NSString *)requestId statusCode:(nullable NSNumber *)statusCode errorContent:(nullable NSString *)errorContent userMessage:(nullable DBLocalizedUserMessage *)userMessage structuredPathRootError: (nonnull DBCOMMONPathRootError *)structuredPathRootError;
Swift
init(asPathRootError requestId: String?, statusCode: NSNumber?, errorContent: String?, userMessage: DBLocalizedUserMessage?, structuredPathRootError: DBCOMMONPathRootError)
Parameters
requestId
The Dropbox request id of the network call. This is useful to Dropbox for debugging issues with Dropbox’s SDKs and API.
statusCode
The HTTP response status code of the request.
errorContent
A string representation of the error body received in the reponse. If for a route-specific error, this field will be the value of the “error_summary” key.
userMessage
An error message object that is optionally returned from some API endpoints.
structuredPathRootError
The structured object returned by the Dropbox API in the event of a 422 path root error.
Return Value
An initialized
DBRequestError
instance with Auth error state. -
DBRequestError convenience constructor.
Initializes the
DBRequestError
with all the required state for representing a Rate Limit error.Declaration
Objective-C
- (nonnull instancetype) initAsRateLimitError:(nullable NSString *)requestId statusCode:(nullable NSNumber *)statusCode errorContent:(nullable NSString *)errorContent userMessage:(nullable DBLocalizedUserMessage *)userMessage structuredRateLimitError: (nonnull DBAUTHRateLimitError *)structuredRateLimitError backoff:(nonnull NSNumber *)backoff;
Swift
init(asRateLimitError requestId: String?, statusCode: NSNumber?, errorContent: String?, userMessage: DBLocalizedUserMessage?, structuredRateLimitError: DBAUTHRateLimitError, backoff: NSNumber)
Parameters
requestId
The Dropbox request id of the network call. This is useful to Dropbox for debugging issues with Dropbox’s SDKs and API.
statusCode
The HTTP response status code of the request.
errorContent
A string representation of the error body received in the reponse. If for a route-specific error, this field will be the value of the “error_summary” key.
userMessage
An error message object that is optionally returned from some API endpoints.
structuredRateLimitError
The structured object returned by the Dropbox API in the event of a 429 rate-limit error.
backoff
The number of seconds to wait before making any additional requests in the event of a rate-limit error.
Return Value
An initialized
DBRequestError
instance with Rate Limit error state. -
DBRequestError
convenience constructor.Initializes the
DBRequestError
with all the required state for representing an Internal Server error.Declaration
Objective-C
- (nonnull instancetype) initAsInternalServerError:(nullable NSString *)requestId statusCode:(nullable NSNumber *)statusCode errorContent:(nullable NSString *)errorContent userMessage:(nullable DBLocalizedUserMessage *)userMessage;
Swift
init(asInternalServerError requestId: String?, statusCode: NSNumber?, errorContent: String?, userMessage: DBLocalizedUserMessage?)
Parameters
requestId
The Dropbox request id of the network call. This is useful to Dropbox for debugging issues with Dropbox’s SDKs and API.
statusCode
The HTTP response status code of the request.
errorContent
A string representation of the error body received in the reponse.
userMessage
An error message object that is optionally returned from some API endpoints. route-specific error, this field will be the value of the “error_summary” key.
Return Value
An initialized
DBRequestError
instance with Internal Server error state. -
DBRequestError
convenience constructor.Initializes the
DBRequestError
with all the required state for representing an “OS” error. An example of such an error might be if you attempt to make a request and are not connected to the internet.Declaration
Objective-C
- (nonnull instancetype)initAsClientError:(nullable NSError *)nsError;
Swift
init(asClientError nsError: Error?)
Parameters
nsError
The client-side
NSError
object returned from the failed response.Return Value
An initialized
DBRequestError
instance with Client error state. -
-init:
requestId: statusCode: errorContent: userMessage: structuredAuthError: structuredAccessError: structuredPathRootError: structuredRateLimitError: backoff: nsError: DBRequestError
full constructor.Declaration
Objective-C
- (nonnull instancetype)init:(DBRequestErrorTag)tag requestId:(nullable NSString *)requestId statusCode:(nullable NSNumber *)statusCode errorContent:(nullable NSString *)errorContent userMessage:(nullable DBLocalizedUserMessage *)userMessage structuredAuthError:(nullable DBAUTHAuthError *)structuredAuthError structuredAccessError:(nullable DBAUTHAccessError *)structuredAccessError structuredPathRootError: (nullable DBCOMMONPathRootError *)structuredPathRootError structuredRateLimitError: (nullable DBAUTHRateLimitError *)structuredRateLimitError backoff:(nullable NSNumber *)backoff nsError:(nullable NSError *)nsError;
Swift
init(_ tag: DBRequestErrorTag, requestId: String?, statusCode: NSNumber?, errorContent: String?, userMessage: DBLocalizedUserMessage?, structuredAuthError: DBAUTHAuthError?, structuredAccessError: DBAUTHAccessError?, structuredPathRootError: DBCOMMONPathRootError?, structuredRateLimitError: DBAUTHRateLimitError?, backoff: NSNumber?, nsError: Error?)
Parameters
requestId
The Dropbox request id of the network call. This is useful to Dropbox for debugging issues with Dropbox’s SDKs and API.
statusCode
The HTTP response status code of the request.
errorContent
A string representation of the error body received in the reponse. If for a route-specific error, this field will be the value of the “error_summary” key.
userMessage
An error message object that is optionally returned from some API endpoints.
structuredAuthError
The structured object returned by the Dropbox API in the event of a 401 auth error.
structuredAccessError
The structured object returned by the Dropbox API in the event of a 403 access error.
structuredPathRootError
The structured object returned by the Dropbox API in the event of a 422 path root error.
structuredRateLimitError
The structured object returned by the Dropbox API in the event of a 429 rate-limit error.
backoff
The number of seconds to wait before making any additional requests in the event of a rate-limit error.
nsError
The client-side NSError object returned from the failed response.
Return Value
An initialized
DBRequestError
instance.
-
Retrieves whether the error’s current tag state has value “http_error”.
Declaration
Objective-C
- (BOOL)isHttpError;
Swift
func isHttpError() -> Bool
Return Value
Whether the union’s current tag state has value “http_error”.
-
Retrieves whether the error’s current tag state has value “bad_input_error”.
Declaration
Objective-C
- (BOOL)isBadInputError;
Swift
func isBadInputError() -> Bool
Return Value
Whether the union’s current tag state has value “bad_input_error”.
-
Retrieves whether the error’s current tag state has value “auth_error”.
Declaration
Objective-C
- (BOOL)isAuthError;
Swift
func isAuthError() -> Bool
Return Value
Whether the union’s current tag state has value “auth_error”.
-
Retrieves whether the error’s current tag state has value “access_error”.
Declaration
Objective-C
- (BOOL)isAccessError;
Swift
func isAccessError() -> Bool
Return Value
Whether the union’s current tag state has value “access_error”.
-
Retrieves whether the error’s current tag state has value “path_root_error”.
Declaration
Objective-C
- (BOOL)isPathRootError;
Swift
func isPathRootError() -> Bool
Return Value
Whether the union’s current tag state has value “path_root_error”.
-
Retrieves whether the error’s current tag state has value “rate_limit_error”.
Declaration
Objective-C
- (BOOL)isRateLimitError;
Swift
func isRateLimitError() -> Bool
Return Value
Whether the union’s current tag state has value “rate_limit_error”.
-
Retrieves whether the error’s current tag state has value “internal_server_error”.
Declaration
Objective-C
- (BOOL)isInternalServerError;
Swift
func isInternalServerError() -> Bool
Return Value
Whether the union’s current tag state has value “internal_server_error”.
-
Retrieves whether the error’s current tag state has value “client_error”.
Declaration
Objective-C
- (BOOL)isClientError;
Swift
func isClientError() -> Bool
Return Value
Whether the union’s current tag state has value “client_error”.
-
Creates a
DBRequestHttpError
instance based on the data in the currentDBRequestError
instance.Note
Will throw error if current
DBRequestError
instance tag state is not “http_error”. Should only use after checking ifisHttpError
returns true for the currentDBRequestError
instance.Declaration
Objective-C
- (nonnull DBRequestHttpError *)asHttpError;
Swift
func asHttpError() -> DBRequestHttpError
Return Value
An initialized
DBRequestHttpError
instance. -
Creates a
DBRequestBadInputError
instance based on the data in the currentDBRequestError
instance.Note
Will throw error if current
DBRequestError
instance tag state is not “bad_input_error”. Should only use after checking ifisBadInputError
returns true for the currentDBRequestError
instance.Declaration
Objective-C
- (nonnull DBRequestBadInputError *)asBadInputError;
Swift
func asBadInputError() -> DBRequestBadInputError
Return Value
An initialized
DBRequestBadInputError
. -
Creates a DBRequestAuthError instance based on the data in the current
DBRequestError
instance.Note
Will throw error if current
DBRequestError
instance tag state is not “auth_error”. Should only use after checking ifisAuthError
returns true for the currentDBRequestError
instance.Declaration
Objective-C
- (nonnull DBRequestAuthError *)asAuthError;
Swift
func asAuthError() -> DBRequestAuthError
Return Value
An initialized
DBRequestAuthError
instance. -
Creates a DBRequestAccessError instance based on the data in the current
DBRequestError
instance.Note
Will throw error if current
DBRequestError
instance tag state is not “auth_error”. Should only use after checking ifisAccessError
returns true for the currentDBRequestError
instance.Declaration
Objective-C
- (nonnull DBRequestAccessError *)asAccessError;
Swift
func asAccessError() -> DBRequestAccessError
Return Value
An initialized
DBRequestAccessError
instance. -
Creates a DBRequestAccessError instance based on the data in the current
DBRequestError
instance.Note
Will throw error if current
DBRequestError
instance tag state is not “auth_error”. Should only use after checking ifisAccessError
returns true for the currentDBRequestError
instance.Declaration
Objective-C
- (nonnull DBRequestPathRootError *)asPathRootError;
Swift
func asPathRootError() -> DBRequestPathRootError
Return Value
An initialized
DBRequestAccessError
instance. -
Creates a
DBRequestRateLimitError
instance based on the data in the currentDBRequestError
instance.Note
Will throw error if current
DBRequestError
instance tag state is not “rate_limit_error”. Should only use after checking ifisRateLimitError
returns true for the currentDBRequestError
instance.Declaration
Objective-C
- (nonnull DBRequestRateLimitError *)asRateLimitError;
Swift
func asRateLimitError() -> DBRequestRateLimitError
Return Value
An initialized
DBRequestRateLimitError
instance. -
Creates a
DBRequestInternalServerError
instance based on the data in the currentDBRequestError
instance.Note
Will throw error if current
DBRequestError
instance tag state is not “internal_server_error”. Should only use after checking ifisInternalServerError
returns true for the currentDBRequestError
instance.Declaration
Objective-C
- (nonnull DBRequestInternalServerError *)asInternalServerError;
Swift
func asInternalServerError() -> DBRequestInternalServerError
Return Value
An initialized
DBHttpError
instance. -
Creates a
DBRequestClientError
instance based on the data in the currentDBRequestError
instance.Note
Will throw error if current
DBRequestError
instance tag state is not “client_error”. Should only use after checking ifisClientError
returns true for the currentDBRequestError
instance.Declaration
Objective-C
- (nonnull DBRequestClientError *)asClientError;
Swift
func asClientError() -> DBRequestClientError
Return Value
An initialized
DBRequestClientError
instance.
-
Retrieves string value of union’s current tag state.
Declaration
Objective-C
- (nonnull NSString *)tagName;
Swift
func tagName() -> String
Return Value
A human-readable string representing the
DBRequestError
object’s current tag state.
-
Description method.
Declaration
Objective-C
- (nonnull NSString *)description;
Swift
func description() -> String
Return Value
A human-readable representation of the current
DBRequestError
object.