What problem does it solve?
This Skill provides a structured guide for managing exceptions and errors in the Cangjie language, including how to distinguish Error vs Exception, define custom exceptions, and implement robust error handling patterns.
Core Features & Use Cases
- Error vs Exception: clearly separates internal system errors from logic errors and shows when to inherit from Exception but not from Error.
- Exception API & Custom Rules: explains how to define custom exceptions using open class inheritance and the allowed rules for extending Exception.
- Control Flow Patterns: covers try/catch/finally, try-with-resources, and various CatchPattern usage to safely handle errors.
- Option-based Error Handling: describes using Option<T> with match, ??, ? and getOrThrow() to manage missing values safely.
- Use Case: implement a small module that validates input, handles potential failures, and ensures resources are cleaned up.
Quick Start
Write a small Cangjie snippet that demonstrates throwing and catching a custom exception inside a try/catch block.