             return
         }
         
-        handler.client?.URLProtocol(handler, didFailWithError: handler.error("err.cancelled"))
+        handler.client?.URLProtocol(handler, didFailWithError: WebCacheError("WebCacheMonk.Cancalled", url: handler.request.URL?.absoluteString))
     }
 }
 

//---------------------------------------------------------------------------

public class WebCacheProtocol : NSURLProtocol {
    public class func prepareToFetch(request: NSURLRequest) -> (NSURL, WebCacheSource)? {
        return nil
    }

    public override final class func canInitWithRequest(request: NSURLRequest) -> Bool {
        guard NSURLProtocol.propertyForKey("WebCache", inRequest: request) == nil else {
            return false
        }

        return prepareToFetch(request) != nil
    }
    
    public override class func canonicalRequestForRequest(request: NSURLRequest) -> NSURLRequest {
        return request
    }
    
    public class func prepareToFetch(request: NSURLRequest) -> (NSURL, WebCacheSource)? {
        // subclass should override this
        return nil
    }

    private var progress: NSProgress?
    private var hasRange = false
    
