docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합

이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영.

- Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들
  (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거.
- Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/
  Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/
  Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이
  존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존).
- Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/
  JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동.
- 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리.
- Topic_Programming 최종 문서 수: 2784 → 3985.
This commit is contained in:
Antigravity Agent
2026-07-05 00:39:13 +09:00
parent 9148c358d0
commit e9cbf23ab5
1356 changed files with 0 additions and 12831 deletions
@@ -0,0 +1,94 @@
---
id: csharp-exceptions
title: "C# Exceptions - Try..Catch"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["try catch finally throw C#", "e.Message", "C# 예외 처리"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.85
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["csharp", "programming-language", "w3schools", "exceptions"]
raw_sources: ["https://www.w3schools.com/cs/cs_exceptions.php"]
applied_in: []
github_commit: ""
---
# [[CSharp Exceptions]]
## 🎯 한 줄 통찰 (One-line insight)
The `try { } catch (Exception e) { } finally { }` structure is functionally identical to C++'s exception handling already documented in `[[CPP Exceptions]]`, but where C++ typically catches by REFERENCE to a specific exception type (`catch (std::exception& e)`) and reads its message via `.what()`, C# catches the generic base `Exception` type and reads the message via a `.Message` PROPERTY (no parentheses — consistent with the property-not-method pattern already confirmed for `.Length` in the Strings chapter); `throw new ArithmeticException("...")` also demonstrates that C# ships a family of ready-made, semantically-named exception classes (`ArithmeticException`, `FileNotFoundException`, `IndexOutOfRangeException`, `TimeOutException`) rather than requiring the programmer to define custom exception types from scratch for common cases. [S1]
## 🧠 핵심 개념 (Core concepts)
- **Exception** — the technical term for an error C# "throws" when something goes wrong (bad input, coding errors, unforeseen conditions). [S1]
- **`try { }`** — a block of code tested for errors during execution. [S1]
- **`catch (Exception e) { }`** — a block that runs IF an error occurs inside the paired `try` block; `e` is a variable holding the exception object. [S1]
- **`e.Message`** — a property (no parentheses) on the caught exception, describing what went wrong. [S1]
- **`finally { }`** — runs AFTER the try/catch, regardless of whether an error occurred or was caught. [S1]
- **`throw new ExceptionType("message")`** — creates and raises a CUSTOM error, using one of C#'s built-in exception classes (`ArithmeticException`, `FileNotFoundException`, `IndexOutOfRangeException`, `TimeOutException`, etc.). [S1]
## 📖 세부 내용 (Details)
- Unhandled error: `int[] myNumbers = {1, 2, 3}; Console.WriteLine(myNumbers[10]);``System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'`. [S1]
- Caught with built-in message: `try { ...myNumbers[10]... } catch (Exception e) { Console.WriteLine(e.Message); }``"Index was outside the bounds of the array."`. [S1]
- Caught with custom message: `catch (Exception e) { Console.WriteLine("Something went wrong."); }``"Something went wrong."` (note: `e` is available but not necessarily used). [S1]
- With `finally`: adding `finally { Console.WriteLine("The 'try catch' is finished."); }` runs that line AFTER the catch block regardless of outcome. [S1]
- Custom throw: `static void checkAge(int age) { if (age < 18) { throw new ArithmeticException("Access denied - You must be at least 18 years old."); } else { Console.WriteLine("Access granted - You are old enough!"); } } ... checkAge(15);` → throws `System.ArithmeticException: 'Access denied...'`; `checkAge(20);` → prints `"Access granted - You are old enough!"`. [S1]
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- **C++의 예외 처리와 구조는 동일, 메시지 접근 방식이 다름**: try/catch/finally 구조 자체는 `[[CPP Exceptions]]`에서 확인된 C++와 차이가 없지만, C++가 보통 `.what()` 메서드로 예외 메시지를 얻는 반면 C#은 `.Message`라는 프로퍼티(괄호 없음)로 접근한다는 점이 확인됨 — Strings 챕터에서 확인된 프로퍼티 vs 메서드 구분이 예외 객체에도 그대로 적용됨. [S1]
- **즉시 사용 가능한 다양한 내장 예외 클래스 제공**: `ArithmeticException`, `FileNotFoundException`, `IndexOutOfRangeException`, `TimeOutException` 등 의미가 명확한 예외 클래스들이 기본 제공되어, throw할 때 매번 커스텀 예외 타입을 새로 정의할 필요가 없다는 점이 확인됨. [S1]
## 🛠️ 적용 사례 (Applied in summary)
나이가 18세 미만이면 ArithmeticException을 throw하고, 18세 이상이면 "Access granted"를 출력하는 checkAge() 함수 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
## 💻 코드 패턴 (Code patterns)
try/catch/finally with a custom throw (C#):
```csharp
static void checkAge(int age)
{
if (age < 18)
{
throw new ArithmeticException("Access denied - You must be at least 18 years old.");
}
else
{
Console.WriteLine("Access granted - You are old enough!");
}
}
try
{
checkAge(15);
}
catch (Exception e)
{
Console.WriteLine(e.Message); // property, no parentheses
}
finally
{
Console.WriteLine("The 'try catch' is finished.");
}
```
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.85
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[C# Tutorial]]
- **관련 개념:** [[CSharp User Input]], [[CSharp Files]], [[CPP Exceptions]], [[CSharp Strings]]
- **참조 맥락:** Exceptions 섹션의 유일 챕터 — Files 섹션으로 이어짐.
## 📚 출처 (Sources)
- [S1] W3Schools — C# Exceptions - Try..Catch — https://www.w3schools.com/cs/cs_exceptions.php
## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Exceptions - Try..Catch" page (Astra wiki-curation, P-Reinforce v3.1 format).