From 7058bb5e12657ff85b13474af352c16624ebcbfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 18 Oct 2016 05:49:12 +0200 Subject: [PATCH] Have DatabaseError adopt CustomNSError --- GRDB/Core/DatabaseError.swift | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/GRDB/Core/DatabaseError.swift b/GRDB/Core/DatabaseError.swift index 2bbf76245..f7aff8a54 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -1,3 +1,5 @@ +import Foundation + #if !USING_BUILTIN_SQLITE #if os(OSX) import SQLiteMacOSX @@ -59,3 +61,21 @@ extension DatabaseError: CustomStringConvertible { return description } } + +extension DatabaseError : CustomNSError { + + /// NSError bridging: the domain of the error. + public static var errorDomain: String { + return "GRDB.DatabaseError" + } + + /// NSError bridging: the error code within the given domain. + public var errorCode: Int { + return Int(code) + } + + /// NSError bridging: the user-info dictionary. + public var errorUserInfo: [String : Any] { + return [NSLocalizedDescriptionKey: description] + } +}