DarkMatterError

@objc public class DarkMatterError: NSObject, Error

A class representing a DarkMatter error.

  • The error message.

    Declaration

    Swift

    public var message: String? = nil
  • The error code.

    Declaration

    Swift

    public var code: Int = DarkMatterErrorCode.NoError.rawValue
  • Data associated with the error.

    Declaration

    Swift

    public var data: [String: Any]? = nil
  • HTTP headers associated with the error.

    Declaration

    Swift

    public var headers: [String: String]? = nil
  • Predefined errors that can be registered with the DarkMatterErrorService.

    Declaration

    Swift

    public static let _dmErrors: [String: ErrorData] = [
  • Initializes the instance with default values.

    Declaration

    Swift

    public override init()
  • Initializes the instance with values from an Alamofire HTTP DataResponse object.

    Declaration

    Swift

    public init(response: DataResponse<Any>)
  • Initializes the instance with the given error code.

    Declaration

    Swift

    public convenience init(code: Int)

    Parameters

    code

    The error code.

  • Initializes the instance with the given error code and message.

    Declaration

    Swift

    public convenience init(code: Int, message: String)

    Parameters

    code

    The error code.

    message

    The error message.

  • Initializes the instance with the given error code, message, and data.

    Declaration

    Swift

    public convenience init(code: Int, message: String, data: [String: Any]?)

    Parameters

    code

    The error code.

    message

    The error message.

    data

    The associated data.

  • Initializes the instance with the given values.

    Declaration

    Swift

    public init(code: Int, message: String, data: [String: Any]?, headers: [String: String]?)

    Parameters

    code

    The error code.

    message

    The error message.

    data

    The associated data.

    headers

    The associated HTTP headers.

  • Converts a DarkMatterErrorCode to a V5 server error code.

    Declaration

    Swift

    public static func getServerCodeForError(error: DarkMatterErrorCode) -> Int

    Parameters

    error

    The dark matter error code.

    Return Value

    The V5 server error code corresponding to the dark matter error.

  • Converts a V5 server error code to a DarkMatterErrorCode.

    Declaration

    Swift

    public static func getErrorForCode(_ code: Int) -> DarkMatterErrorCode

    Parameters

    code

    V5 server error code.

    Return Value

    The corresponding DarkMatterErrorCode.

  • Used to determine if a network request should be retried based on the status code.

    Declaration

    Swift

    public static func shouldRetry(code: Int) -> Bool

    Parameters

    code

    The HTTP status code.

    Return Value

    true if the network request should be retried.

  • Returns a string that represents the code and message of the DarkMatterError class.

    Declaration

    Swift

    public override var description: String
  • Creates a verbose string description of the DarkMatterError class.

    Declaration

    Swift

    public func toStringVerbose() -> String

    Return Value

    A string that is the description with the data and headers appended to it.