Exception Hierarchy
Exceptions in Cangjie form a hierarchy with Exception as the root. The standard library provides various exception types, such as IndexOutOfBoundsException (array index out of bounds), ArithmeticException (arithmetic errors), IllegalArgumentException (illegal arguments), etc., all inheriting from Exception.
When there are multiple catch clauses in a try block, exceptions are matched from top to bottom. Once a catch matches successfully, all subsequent catch clauses are skipped. Therefore, more specific exception types should be placed before more general exception types.
If you place a generic catch (e: Exception) before specific types, the subsequent specific exception types will never be matched. The compiler will issue a warning about this.
catch blocks.Try modifying the code by changing the first catch block to catch Exception and observe the compiler's warning message.