> On Aug 14, 2016, at 1:18 AM, Jon Shier via swift-evolution > <swift-evolution@swift.org> wrote: > > An immediate problem I’m seeing is the error: using 'Error' as a > concrete type conforming to protocol 'Error' is not supported, which means we > can’t use Error in our Result or Response types, as both the value and error > types are generic there. I’m guessing we’ll have to either remove the generic > error type, which would greatly impact consumer’s ability to use our APIs > with their own custom errors, or wrap all errors in our own error type, which > is terrible for a few reasons. Or just keep using NSError I guess. Any clever > solutions here?
Works fine when I try it: import Foundation struct MyThing { enum Error: Swift.Error, LocalizedError { case doesNotCompute case imSorryDave case mustSterilize var failureReason: String? { switch self { case .doesNotCompute: return "Does Not Compute! Does Not Compute! Does Not Compute!" case .imSorryDave: return "I'm sorry Dave, I'm afraid I can't do that." case .mustSterilize: return "Error! Must Sterilize! Must Steeerrrrilllliiiiiiizzzzzzeeeeeee" } } } func trySomething() throws { throw Error.doesNotCompute } } let thing = MyThing() do { try thing.trySomething() } catch { print(error.localizedDescription) } Outputs: The operation couldn’t be completed. Does Not Compute! Does Not Compute! Does Not Compute! Charles
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution