@@ -714,8 +714,9 @@ XXX OUTLINE XXX
714714- A boxed protocol (aka existential) type matches the reality of most code.
715715 At compile time, you don't know every possible way things could go wrong.
716716 In particular, some errors will come from calling other throwing functions.
717+ This is why most code uses a boxed protocol type as its error type.
717718
718- - In contrast, a concrete error type is useful:
719+ - In contrast, a concrete error type is useful in some special circumstances :
719720
720721 * When the code that throws errors
721722 and the code that handles those errors
@@ -726,6 +727,7 @@ XXX OUTLINE XXX
726727
727728 * In code that only rethrows errors,
728729 especially when the throwing code comes from a closure the caller provided.
730+ (However, neither rethrows nor typed throws is a strict superset of the other.)
729731 Example: ` map ` in the stdlib.
730732 Xref to reference section -- this chapter doesn't discuss rethrows
731733
@@ -742,6 +744,7 @@ XXX OUTLINE XXX
742744 this is still "concrete" in sense that
743745 the errors are all instances of the concrete type
744746 that's hidden behind the opaque type.
747+ And there's still one specific error type.
745748
746749- To specify the error type for a ` do ` block or a throwing function,
747750 write ` throws(E) ` where ` E ` is an error type.
@@ -753,8 +756,11 @@ XXX OUTLINE XXX
753756
754757- For a normal error (of boxed protocol type)
755758 the ` catch ` clause needs to either include a general catch/default
759+ that handles errors whose types the other clauses don't handle,
756760 or to propagate the errors it doesn't handle.
757- For a typed error, the catch clause can be exhaustive.
761+ For a typed error, the catch clause can be exhaustive
762+ without a default clause
763+ by handling just that specific error type.
758764
759765XXX RUNNING EXAMPLE XXX
760766
0 commit comments