LineSDKError
public enum LineSDKError : Error
extension LineSDKError: LocalizedError
extension LineSDKError: CustomNSError
Error types returned by the LINE SDK. It encompasses different types of errors that have their own associated reasons.
You can switch over to each error to find out the reason of the error and its associated information. You can also
access the localizedDescription
property to get a human-readable text description. Access errorCode
to get a fixed error code to identify the error type quickly. All LineSDKError
s are under the
“LineSDKError” error domain.
- requestFailed: An error occurred while constructing a request.
- responseFailed: An error occurred while handling a response.
- authorizeFailed: An error occurred while authorizing a user.
- generalError: An error occurred while performing another process in the LINE SDK.
- untypedError: An error not defined in the LINE SDK occurred.
-
The possible underlying reasons a
.requestFailed
error occurs.- missingURL: The
URL
object is missing while encoding a request. Code 1001. - lackOfAccessToken: The request requires an access token but it is unavailable. Code 1002.
- jsonEncodingFailed: The request requires a JSON body but the provided data cannot be encoded to valid JSON. Code 1003.
Declaration
Swift
public enum RequestErrorReason
- missingURL: The
-
The possible underlying reasons a
.responseFailed
error occurs.- URLSessionError: An error occurred in the underlying
URLSession
object. Code 2001. - nonHTTPURLResponse: The response is not a valid
HTTPURLResponse
object. Code 2002. - dataParsingFailed: The received data cannot be parsed to an instance of the target type. Code 2003.
- invalidHTTPStatusAPIError: The received response contains an invalid HTTP status code. Code 2004.
Declaration
Swift
public enum ResponseErrorReason
- URLSessionError: An error occurred in the underlying
-
The possible underlying reasons an
.authorizeFailed
error occurs.- exhaustedLoginFlow: There is no other login method left. The login process cannot be completed. Code 3001.
- malformedHierarchy: The view hierarchy or view controller hierarchy is malformed and the LINE SDK cannot show its login view controller. Code 3002.
- userCancelled: The user cancelled or interrupted the login process. Code 3003.
- forceStopped: The
stop
method is called during the login process. Code 3004. - callbackURLSchemeNotMatching: The received
URL
object while opening the app does not match the defined URL scheme. Code 3005. - invalidSourceApplication: The source application is invalid and cannot finish the authorization process. Not in use anymore from LINE SDK 5.2.4. Code 3006.
- malformedRedirectURL: The received
URL
object while opening the app is invalid or does not contain necessary information. Code 3007. - invalidLineURLResultCode: The received
URL
object while opening the app has an unknown result code. Code 3008. - lineClientError: An error occurs in LINE during the authorization process. Code 3009.
- responseStateValueNotMatching: Failed to verify the
state
value. The received URL response is not from the original authorization request. Code 3010. - webLoginError: An error occurs in the web login flow during the authorization process. Code 3011.
- keychainOperation: An error occurs while accessing the keychain. It prevents the LINE SDK from loading data from or writing data to the keychain. Code 3012.
- invalidDataInKeychain: The retrieved authorization information from the keychain cannot be converted to valid data. Code 3013.
- lackOfIDToken: The authorization request contains the OpenID scope, but any ID token is not found in or parsed from the server response. Code 3014.
- JWTPublicKeyNotFound: The public key is not found for a give key ID or the key ID does not exist. Code 3015.
- cryptoError: An error occurred at the LINE SDK crypto part. Usually this indicates a malformed
certificate or a key, or an unsupported algorithm is used. For more information, see
CryptoError
. Code 3016.
Declaration
Swift
public enum AuthorizeErrorReason
-
The possible underlying reasons
.generalError
occurs.- conversionError: Cannot convert
string
to valid data withencoding
. Code 4001. - parameterError: The method is invoked with an invalid parameter. Code 4002.
- notOriginalTask: The image download task finished but it is not the original task issued. Code 4003.
- processDiscarded: The process is discarded when a new login process is created. This only
happens when
allowRecreatingLoginProcess
inLoginManager.Parameters
istrue
and users are trying to create another login process. Code 4004.
Declaration
Swift
public enum GeneralErrorReason
- conversionError: Cannot convert
-
An error occurred while constructing a request.
Declaration
Swift
case requestFailed(reason: RequestErrorReason)
-
An error occurred while handling a response.
Declaration
Swift
case responseFailed(reason: ResponseErrorReason)
-
An error occurred while authorizing a user.
Declaration
Swift
case authorizeFailed(reason: AuthorizeErrorReason)
-
An error occurred while performing another process in the LINE SDK.
Declaration
Swift
case generalError(reason: GeneralErrorReason)
-
An error not defined in the LINE SDK occurred.
Declaration
Swift
case untypedError(error: Error)
-
Checks and returns whether the
LineSDKError
is a request error.Declaration
Swift
public var isRequestError: Bool { get }
-
Checks and returns whether the
LineSDKError
is a response error.Declaration
Swift
public var isResponseError: Bool { get }
-
Checks and returns whether the
LineSDKError
is an authorization error.Declaration
Swift
public var isAuthorizeError: Bool { get }
-
Checks and returns whether the
LineSDKError
is a general error.Declaration
Swift
public var isGeneralError: Bool { get }
-
Checks and returns whether the
LineSDKError
is an authorization error and the reason is.userCancelled
.Declaration
Swift
public var isUserCancelled: Bool { get }
-
Checks and returns whether the
LineSDKError
is a bad request error.Declaration
Swift
public var isBadRequest: Bool { get }
-
Checks and returns whether the
LineSDKError
is a refresh token error. Typically, when the user uses an expired access token to send a public API request, an automatic token refresh operation with the current refresh token will be triggered. This error typically occurs when the refresh token also expires or is invalid. If this error occurs, let the user log in again before you can continue to access the LINE Platform.Declaration
Swift
public var isRefreshTokenError: Bool { get }
-
Checks and returns whether the
LineSDKError
is a permission error. This typically means you do not have sufficient permissions to access an endpoint of the LINE Platform.Declaration
Swift
public var isPermissionError: Bool { get }
-
Checks and returns whether the
LineSDKError
is an access token error. Usually, it means the user’s access token is expired or malformed.Declaration
Swift
public var isTokenError: Bool { get }
-
Checks whether this lineSDKError object’s status code matches a specified value.
Declaration
Swift
public func isResponseError(statusCode: Int) -> Bool
Parameters
statusCode
The HTTP status code to compare against the
LineSDKError
object.Return Value
true
ifself
is an.invalidHTTPStatusAPIError
with the givenstatusCode
;false
otherwise. -
Checks and returns whether the
LineSDKError
is a timeout error caused by the underlying URL session error.Declaration
Swift
public var isURLSessionTimeOut: Bool { get }
-
Checks whether the
LineSDKError
is a URL session error with a specified error code.Declaration
Swift
public func isURLSessionErrorCode(sessionErrorCode code: Int) -> Bool
Parameters
code
The underlying URL session error code. See
URLError
in the documentation for the Foundation framework.Return Value
true
ifself
is a.URLSessionError
error with the givencode
;false
otherwise.
-
Describes the cause of an error in human-readable text.
Declaration
Swift
public var errorDescription: String? { get }
-
Declaration
Swift
public var errorCode: Int { get }