cangjie-error-handle

Explain Cangjie error handling with exceptions, Option<T>, and try/catch/finally.

1|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-error-handle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-error-handle
Source: https://github.com/SunriseSummer/CangjieDocValidator/tree/main/.github/skills/error_handle
Command: npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-error-handle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers understand and implement robust error handling mechanisms within the Cangjie programming language, preventing unexpected crashes and improving application stability.

Core Features & Use Cases

  • Exception Hierarchy: Learn about Error vs. Exception and how to define custom exceptions.
  • Error Handling Constructs: Master throw, try/catch/finally, and try-with-resources for managing runtime issues.
  • Option Type: Utilize Option<T> (?T) with pattern matching, ??, ?, and getOrThrow() for safer value handling.
  • Use Case: Debugging a complex application that frequently throws exceptions, and needing to implement precise error handling to gracefully manage different failure scenarios.

Quick Start

Use the cangjie-error-handle skill to demonstrate how to catch a NegativeArraySizeException using a try-catch block.

Frequently Asked Questions about cangjie-error-handle

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle exceptions in Cangjie using try-catch-finally blocks?

Cangjie exception handling uses try, catch, and finally blocks to manage runtime errors. You throw exceptions explicitly and catch specific hierarchy types like NegativeArraySizeException to prevent application crashes gracefully.

What is the Option<T> type in Cangjie and how does it handle null values?

The Option<T> type in Cangjie represents potential value absence. You handle it using pattern matching, the ?? coalescing operator, optional chaining ?, or getOrThrow() to safely extract values without runtime crashes.

How do I define custom exceptions in the Cangjie programming language?

Defining custom exceptions in Cangjie involves extending the exception hierarchy, distinguishing between Error and Exception types. You create custom classes and throw them using the throw statement for specific application failure scenarios.

What is the try-with-resources statement in Cangjie used for?

The try-with-resources statement in Cangjie manages resource cleanup automatically. It ensures resources are closed properly when execution exits the block, preventing leaks alongside standard try-catch-finally error handling.

What built-in runtime exceptions does Cangjie have?

Cangjie includes built-in runtime exceptions like ConcurrentModificationException and NoneValueException. These handle specific runtime failure scenarios, such as concurrent collection modification or unexpected missing values.

When should I use Option<T> versus exceptions for error handling in Cangjie?

Use Option<T> for expected value absences and exceptions for unexpected runtime failures. Option<T> uses pattern matching and optional chaining for safe access, while exceptions use try-catch blocks for managing critical errors.