<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">It is possible in a lighter project, but its no fun to build an ErrorType for this:&nbsp;http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd/sys/errno.h</div> <div><br></div><div>Here is a snippet from my current project I’m working on:</div><div><br></div><div><div><b>public enum TCPBug: ErrorType {</b></div><div><span class="Apple-tab-span" style="white-space:pre"><b>        </b></span></div><div><b><span class="Apple-tab-span" style="white-space:pre">        </span>case NetworkError(code: Int32, message: String)</b></div><div><b><span class="Apple-tab-span" style="white-space:pre">        </span>case FileError(code: Int32, message: String)</b></div><div><span class="Apple-tab-span" style="white-space:pre"><b>        </b></span></div><div><b><span class="Apple-tab-span" style="white-space:pre">        </span>@noreturn private static func raise(type: TCPBugType) throws {</b></div><div><span class="Apple-tab-span" style="white-space:pre"><b>                </b></span></div><div><b><span class="Apple-tab-span" style="white-space:pre">                </span>let errorCode = errno</b></div><div><b><span class="Apple-tab-span" style="white-space:pre">                </span>let errorMessage = String.fromCString(strerror(errorCode))!</b></div><div><span class="Apple-tab-span" style="white-space:pre"><b>                </b></span></div><div><b><span class="Apple-tab-span" style="white-space:pre">                </span>switch type {</b></div><div><span class="Apple-tab-span" style="white-space:pre"><b>                        </b></span></div><div><b><span class="Apple-tab-span" style="white-space:pre">                </span>case .Network:</b></div><div><b><span class="Apple-tab-span" style="white-space:pre">                        </span>throw TCPBug.NetworkError(code: errorCode, message: errorMessage)</b></div><div><b><span class="Apple-tab-span" style="white-space:pre">                </span>case .File:</b></div><div><b><span class="Apple-tab-span" style="white-space:pre">                        </span>throw TCPBug.FileError(code: errorCode, message: errorMessage)</b></div><div><b><span class="Apple-tab-span" style="white-space:pre">                </span>}</b></div><div><b><span class="Apple-tab-span" style="white-space:pre">        </span>}</b></div><div><b>}</b></div></div><div><br></div>As you might guess from errno.h there are a lot a different errors that could be thrown. And as I described in my previous post I could handle errors where they occur, so there won’t be any new pyramid.&nbsp;<div><br></div><div>Anyways, from my perspective Swift does need a single '<b>do try catch</b>‘ mechanism which escapes the '<b>do { }</b>‘ scope. The only one problem we found is that declaring a new constant/variable inside a single ‘<b>do try catch</b>’ statement can not fall through from the catch body (like the '<b>guard'</b> mechanism).</div><div><br></div><div>Best regards,<span style="font-family: helvetica, arial;">&nbsp;</span><div id="bloop_sign_1454742529765136128" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">Adrian Zubarev<br></div></div></div></body></html>