Skip to content

Commit

Permalink
[Issue Alamofire#668] Made the static error convenience functions pub…
Browse files Browse the repository at this point in the history
…lic.
  • Loading branch information
cnoon committed Aug 11, 2015
1 parent 52dae79 commit 85b90fe
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Source/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,27 @@ public struct Error {
case PropertyListSerializationFailed = -6007
}

static func errorWithCode(code: Code, failureReason: String) -> NSError {
/**
Creates an `NSError` with the given error code and failure reason.

- parameter code: The error code.
- parameter failureReason: The failure reason.

- returns: An `NSError` with the given error code and failure reason.
*/
public static func errorWithCode(code: Code, failureReason: String) -> NSError {
return errorWithCode(code.rawValue, failureReason: failureReason)
}

static func errorWithCode(code: Int, failureReason: String) -> NSError {
/**
Creates an `NSError` with the given error code and failure reason.

- parameter code: The error code.
- parameter failureReason: The failure reason.

- returns: An `NSError` with the given error code and failure reason.
*/
public static func errorWithCode(code: Int, failureReason: String) -> NSError {
let userInfo = [NSLocalizedFailureReasonErrorKey: failureReason]
return NSError(domain: Domain, code: code, userInfo: userInfo)
}
Expand Down

0 comments on commit 85b90fe

Please sign in to comment.