<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 12, 2016 at 2:27 PM, Sean Heber <span dir="ltr"><<a href="mailto:sean@fifthace.com" target="_blank">sean@fifthace.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
> With the improved syntax, this could look something like this instead:<br>
><br>
> enum FileError: Error, LocalizedError {<br>
> var url: URL { get }<br>
><br>
> case notFound(url: URL) {<br>
> errorDescription = "Could not access the file \(url.lastPathComponent) because it could not be found."<br>
> failureReason = "The file \(url.lastPathComponent) could not be found."<br>
> recoverySuggestion = "Please locate the correct file and try again."<br>
> helpAnchor = "notFound"<br>
> url = url<br>
> }<br>
><br>
> case accessDenied(url: URL) {<br>
> errorDescription = "Could not access the file \(url.lastPathComponent) because access was denied."<br>
> failureReason = "We do not have permission to view the file \(url.lastPathComponent)"<br>
> recoverySuggestion = "You can change the file's permissions using the Finder's Get Info window."<br>
> helpAnchor = "accessDenied"<br>
> url = url<br>
> }<br>
><br>
> case incorrectFormat(url: URL) {<br>
> errorDescription = "Could not access the file \(url.lastPathComponent) because it was not in the expected format."<br>
> failureReason = "The file \(url.lastPathComponent) was not in the expected format."<br>
> recoverySuggestion = "The file may have become corrupt."<br>
> helpAnchor = "incorrectFormat"<br>
> url = url<br>
> }<br>
><br>
> case ioError(url: URL) {<br>
> errorDescription = "Could not access the file \(url.lastPathComponent) because an I/O error occurred."<br>
> failureReason = "An I/O error occurred while accessing the file \(url.lastPathComponent)."<br>
> recoverySuggestion = "Dear Lord, the hard drive may be failing."<br>
> helpAnchor = "ioError"<br>
> url = url<br>
> }<br>
><br>
> // ... etc ...<br>
> }<br>
><br>
> I don’t think it can be denied that the second is orders of magnitude easier to read and comprehend.<br>
><br>
> Charles<br>
<br>
</div></div>I’m 100% in favor of something approaching this syntax where the case-specific values are all grouped by the case and not the other way around.<br></blockquote><div><br></div><div>This particular suggestion has been made multiple times in the past. It is a proposal for sugar that did not converge on a consensus during either Swift 2 or 3 evolution. Since sugar is not in scope now and is still low priority for phase 2, let's focus on the potentially ABI-impacting issues here.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
l8r<br>
<span class="HOEnZb"><font color="#888888">Sean<br>
<br>
<br>
<br>
</font></span></blockquote></div><br></div></div>