<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Right now, it's because throws does not specify a type to be thrown, and the compiler doesn't know that you've checked all the possibilities. For all it knows, it could be something else than a MyError.<br class="">
<br class=""><div><blockquote type="cite" class=""><div class="">Le 18 déc. 2015 à 21:28:41, Ricardo Parada via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Thanks for the clarification. &nbsp;Why is the compiler saying that the catch is not exhaustive when it is covering all the possible values of the enum? &nbsp;Is it to be able to catch future values added to the enum type?</span><div class="" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 18, 2015, at 8:05 PM, David Owens II &lt;<a href="mailto:david@owensd.io" class="">david@owensd.io</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 18, 2015, at 4:38 PM, Ricardo Parada &lt;<a href="mailto:rparada@mac.com" class="">rparada@mac.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class=""><div class=""><div class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">Hi David</span></div><div class=""><span class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">I started reading your proposal and I have a couple of questions.&nbsp;</span></div><div class=""><span class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">In the Enum Base ErrorType example you mentioned that it requires a "catch { }" clause. &nbsp;However the code is already covering the two possible Enum values (OffBy1 and MutatedValue). Why is the "catch { }" required? I typed that code into a playground and I did not get any errors. Are you saying that because the Enum type could add a value in the future?</span></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Playgrounds are basically in an anonymous function that throws, so the problem doesn’t show up there at the top level. Copy this into your playground.</div><div class=""><br class=""></div></div><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class=""><div class=""><font face="Menlo" class="">enum&nbsp;MyError:&nbsp;ErrorType&nbsp;{</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;case&nbsp;OnlyOne</font></div></div><div class=""><div class=""><font face="Menlo" class="">}</font></div></div><div class=""><div class=""><font face="Menlo" class=""><br class=""></font></div></div><div class=""><div class=""><font face="Menlo" class="">func&nbsp;thrower()&nbsp;throws&nbsp;{&nbsp;throw&nbsp;MyError.OnlyOne&nbsp;}</font></div></div><div class=""><div class=""><font face="Menlo" class=""><br class=""></font></div></div><div class=""><div class=""><font face="Menlo" class="">func&nbsp;nolies() {</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;do&nbsp;{</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;try&nbsp;thrower()</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;}</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;catch&nbsp;MyError.OnlyOne {&nbsp;print("handled") }</font></div></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; &nbsp; //&nbsp;catch&nbsp;{&nbsp;print("compiler error until uncommented") }</font></div></div><div class=""><div class=""><font face="Menlo" class="">}</font></div></div></blockquote><div class=""><div class=""><br class=""></div><blockquote type="cite" class=""><div dir="auto" class=""><div class=""><div class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">Also, you proposed the catch clause to use error as the name of the constant holding the error. &nbsp;Wouldn't it be better to let the programmer decide the name rather than hard coding it to use error? For example:</span></div><div class=""><span class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">catch e where e.value == 0 { print("0") }</span></div><div class=""><div class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">catch e where e.value == 1 { print("1") }</span></div><div class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">catch { print("nothing") }</span></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">The “error” name is already specified in the Swift rules for what the constant is. I don’t see any compelling reason to propose a change to that.</div><div class=""><br class=""></div><div class="">-David</div></div></div></div></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=iRI3beHTe3UxYAHTlV3lA38zIPfHMhyuRzgTmGKV6k76QZgut3-2B-2Fv-2BkvRgP7wWGixHiIj-2BjwYkD9BXaAZU-2FDEUyfqtP5Voh0P7fqNmKStiuEhEt-2B8yELCgCGtXMTW4UvKxTNyhJuWNaxNilklL6yxxpFmXkJFGMpLXzgi6cUNgO57e7hMjYWnHWFQ9lHcU-2BBjo-2F9mltmOKkb9pxxhlkLFD-2Bq5M42-2FCP4biKYiw-2FlRHw-3D" alt="" width="1" height="1" border="0" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span></span><span style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></body></html>