Skip to content

Commit

Permalink
feat: Enabling pattern matching on JWTErrors (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcrestfield authored and Andrew-Lees11 committed Mar 18, 2019
1 parent a3fecfb commit e7b5111
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/SwiftJWT/JWTError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ public struct JWTError: Error, Equatable {
public static func == (lhs: JWTError, rhs: JWTError) -> Bool {
return lhs.internalError == rhs.internalError
}

/// Function to enable pattern matching against generic Errors.
public static func ~= (lhs: JWTError, rhs: Error) -> Bool {
guard let rhs = rhs as? JWTError else {
return false
}
return lhs == rhs
}
}

0 comments on commit e7b5111

Please sign in to comment.