//
//  TODOAPIClientError.swift
//  KataTODOAPIClient
//
//  Created by Pedro Vicente Gomez on 12/02/16.
//  Copyright © 2016 Karumi. All rights reserved.
//

import Foundation
import Result
import BothamNetworking

public enum TODOAPIClientError: ErrorType {

    case NetworkError
    case ItemNotFound
    case UnknownError(code: Int)

}

extension ResultType where Error == BothamAPIClientError {

    func mapErrorToTODOAPIClientError() -> Result<Value, TODOAPIClientError> {
        return mapError { error in
            switch error {
            case BothamAPIClientError.HTTPResponseError(404, _):
                return TODOAPIClientError.ItemNotFound
            case BothamAPIClientError.HTTPResponseError(let statusCode, _):
                return TODOAPIClientError.UnknownError(code: statusCode)
            default:
                return TODOAPIClientError.NetworkError
            }
        }
    }
}
//
//  TODOAPIClientError.swift
//  KataTODOAPIClient
//
//  Created by Pedro Vicente Gomez on 12/02/16.
//  Copyright © 2016 Karumi. All rights reserved.
//

import Foundation

public enum TODOAPIClientError: ErrorType {

    case NetworkError
    case ItemNotFound
    case UnknownError

}
--- 
+++ 
@@ -7,11 +7,29 @@
 //
 
 import Foundation
+import Result
+import BothamNetworking
 
 public enum TODOAPIClientError: ErrorType {
 
     case NetworkError
     case ItemNotFound
-    case UnknownError
+    case UnknownError(code: Int)
 
 }
+
+extension ResultType where Error == BothamAPIClientError {
+
+    func mapErrorToTODOAPIClientError() -> Result<Value, TODOAPIClientError> {
+        return mapError { error in
+            switch error {
+            case BothamAPIClientError.HTTPResponseError(404, _):
+                return TODOAPIClientError.ItemNotFound
+            case BothamAPIClientError.HTTPResponseError(let statusCode, _):
+                return TODOAPIClientError.UnknownError(code: statusCode)
+            default:
+                return TODOAPIClientError.NetworkError
+            }
+        }
+    }
+}
Add a method to be able to transform BothamError into Todo api client errors
