 	
 	// MARK: Initialization
 	
-	public init(destination: CacheDestination) {
+	public init(destination: CacheDestination) throws {
 		switch destination {
 		case .temporary:
 			self.destination = URL(fileURLWithPath: NSTemporaryDirectory())


extension Cachable where Self: Codable {
	public func transform() -> Data {
		guard let encoded = try? JSONEncoder().encode(self) else {
			fatalError("Unable to encode object")
		}
		return encoded
	}
}

	///
	/// - Parameter fileName: of the cached data stored in the file system
	/// - Returns: the decoded cached data (if any)
	public func load<T: Cachable & Codable>(fileName: String) throws -> T {
		do {
			let data = try Data(contentsOf: destination.appendingPathComponent(fileName, isDirectory: false))
			let decoded = try JSONDecoder().decode(T.self, from: data)
			return decoded
		} catch let error {
			throw error
		}
	}
	
	// MARK: Private
	
	private func persist(data: Data, at url: URL) throws -> URL {
		do {
			try data.write(to: url, options: [.atomicWrite])
			return url
		} catch let error {
			throw error
		}
	}
}
