AppAuth
Class Methods | List of all members
OIDErrorUtilities Class Reference

Convenience methods for creating standardized NSError instances. More...

#import <OIDErrorUtilities.h>

Inheritance diagram for OIDErrorUtilities:

Class Methods

(NSError *) + errorWithCode:underlyingError:description:
 Creates a standard NSError from an OIDErrorCode and custom user info. Automatically populates the localized error description. More...
 
(NSError *) + OAuthErrorWithDomain:OAuthResponse:underlyingError:
 Creates a standard NSError from an OIDErrorCode and custom user info. Automatically populates the localized error description. More...
 
(NSError *) + resourceServerAuthorizationErrorWithCode:errorResponse:underlyingError:
 Creates a NSError indicating that the resource server responded with an authorization error. More...
 
(NSError *) + HTTPErrorWithHTTPResponse:data:
 Creates a standard NSError from an NSHTTPURLResponse. Automatically populates the localized error description with the response data associated with the NSHTTPURLResponse, if available. More...
 
(void) + raiseException:
 Raises an exception with the given name as both the name, and the message. More...
 
(void) + raiseException:message:
 Raises an exception with the given name and message. More...
 
(OIDErrorCodeOAuth+ OAuthErrorCodeFromString:
 Converts an OAuth error code into an OIDErrorCodeOAuth error code. More...
 
(BOOL) + isOAuthErrorDomain:
 Returns true if the given error domain is an OAuth error domain. More...
 

Detailed Description

Convenience methods for creating standardized NSError instances.

Method Documentation

◆ errorWithCode:underlyingError:description:()

+ (NSError *) errorWithCode: (OIDErrorCode code
underlyingError: (nullable NSError *)  underlyingError
description: (nullable NSString *)  description 

Creates a standard NSError from an OIDErrorCode and custom user info. Automatically populates the localized error description.

Parameters
codeThe error code.
underlyingErrorThe underlying error which occurred, if applicable.
descriptionA custom description, if applicable.
Returns
An NSError representing the error code.

◆ HTTPErrorWithHTTPResponse:data:()

+ (NSError *) HTTPErrorWithHTTPResponse: (NSHTTPURLResponse *)  HTTPURLResponse
data: (nullable NSData *)  data 

Creates a standard NSError from an NSHTTPURLResponse. Automatically populates the localized error description with the response data associated with the NSHTTPURLResponse, if available.

Parameters
HTTPURLResponseThe response which indicates an error occurred.
dataThe response data associated with the response which should be converted to an NSString assuming a UTF-8 encoding, if available.
Returns
An NSError representing the error.

◆ isOAuthErrorDomain:()

+ (BOOL) isOAuthErrorDomain: (NSString *)  errorDomain

Returns true if the given error domain is an OAuth error domain.

Parameters
errorDomainThe error domain to test. @discussion An OAuth error domain is used for errors returned per RFC6749 sections 4.1.2.1 and 5.2. Other errors, such as network errors can also occur but they will not have an OAuth error domain.
See also
https://tools.ietf.org/html/rfc6749#section-4.1.2.1
https://tools.ietf.org/html/rfc6749#section-5.2

◆ OAuthErrorCodeFromString:()

+ (OIDErrorCodeOAuth) OAuthErrorCodeFromString: (NSString *)  errorCode

Converts an OAuth error code into an OIDErrorCodeOAuth error code.

Parameters
errorCodeThe OAuth error code. @discussion Returns OIDErrorCodeOAuthOther if the string is not in AppAuth's list.
See also
https://tools.ietf.org/html/rfc6749#section-4.1.2.1
https://tools.ietf.org/html/rfc6749#section-5.2

◆ OAuthErrorWithDomain:OAuthResponse:underlyingError:()

+ (NSError *) OAuthErrorWithDomain: (NSString *)  OAuthErrorDomain
OAuthResponse: (NSDictionary *)  errorResponse
underlyingError: (nullable NSError *)  underlyingError 

Creates a standard NSError from an OIDErrorCode and custom user info. Automatically populates the localized error description.

Parameters
OAuthErrorDomainThe OAuth error domain. Must be OIDOAuthAuthorizationErrorDomain or OIDOAuthTokenErrorDomain.
errorResponseThe dictionary from an OAuth error response (as per RFC6749 Section 5.2).
underlyingErrorThe underlying error which occurred, if applicable.
Returns
An NSError representing the OAuth error.
See also
https://tools.ietf.org/html/rfc6749#section-5.2

◆ raiseException:()

+ (void) raiseException: (NSString *)  name

Raises an exception with the given name as both the name, and the message.

Parameters
nameThe name of the exception.

◆ raiseException:message:()

+ (void) raiseException: (NSString *)  name
message: (NSString *)  message 

Raises an exception with the given name and message.

Parameters
nameThe name of the exception.
messageThe message of the exception.

◆ resourceServerAuthorizationErrorWithCode:errorResponse:underlyingError:()

+ (NSError *) resourceServerAuthorizationErrorWithCode: (NSInteger)  code
errorResponse: (nullable NSDictionary *)  errorResponse
underlyingError: (nullable NSError *)  underlyingError 

Creates a NSError indicating that the resource server responded with an authorization error.

Parameters
codeYour error code.
errorResponseThe resource server error response, if any.
underlyingErrorThe underlying error which occurred, if applicable.
Returns
An NSError representing the authorization error from the resource server.

The documentation for this class was generated from the following file: