Skip to content

Commit

Permalink
Fix for linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
proggeramlug committed May 9, 2018
1 parent be9c50c commit ac0a385
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/APIErrorMiddleware/APIErrorMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ public final class APIErrorMiddleware: Middleware, Service, ServiceType {
// status code and error message.
// Assign the data to the correct varaibles.
result = ErrorResult(message: error.reason, status: error.status)
} else if result == nil {
} else if result == nil, let error = error as? CustomStringConvertible {

// We have some other error.
// Set the message to the error's `description`.
let error = error as CustomStringConvertible
result = ErrorResult(message: error.description, status: nil)
} else if result == nil {
result = ErrorResult(message: "Unknown error.", status: nil)
}

// Create JSON with an `error` key with the `message` constant as its value.
Expand Down

0 comments on commit ac0a385

Please sign in to comment.