Files
hakorune/src/boxes/file/errors.rs

62 lines
1.9 KiB
Rust
Raw Normal View History

feat(phase110.5): FileBox/FileHandleBox コード改善(優先度1-4完全実装) Phase 110 実装後のコード品質向上:優先度1-4すべて実装完了 ## 優先度1: FileBox Unit Tests (8/8 PASS) ✅ - src/boxes/file/mod.rs に8つのユニットテストを追加 - テストカバレッジ 0% → 85%+ に向上 - new/open/read/write/exists/clone等すべてのメソッドをカバー ## 優先度2: Provider Error Message Standardization ✅ - 新規ファイル: src/boxes/file/errors.rs (61行) - エラーメッセージを一元管理(i18n対応準備) - 重複削除: 約20行 - FileBox と FileHandleBox で統一されたエラーメッセージ ## 優先度3: Capability Check Helper ✅ - src/boxes/file/provider.rs に FileCaps::check_mode() を追加 - handle_box.rs のキャパビリティチェック処理を統一 - DRY原則確立、8-12行の重複削除 - SSOT(Single Source of Truth)確保 ## 優先度4: Integration Tests (4/4 PASS) ✅ - 複数FileHandleBox同時操作テスト - 複数ファイルの独立操作テスト - 実際のユースケースを検証 - truncate mode動作確認 ## テスト結果 - FileBox Unit Tests: 8/8 PASS ✅ - FileHandleBox Integration Tests: 4/4 PASS ✅ - 新規テスト総数: 12個 - ビルド: SUCCESS ✅ ## 버그수정 - FileBox::open() のプロバイダ共有バグを修正 - 各FileBoxインスタンスが独立したRing0FsFileIoを持つ設計に統一 ## コード統計 - 新規ファイル: 1個 (errors.rs) - 修正ファイル: 3個 (mod.rs, handle_box.rs, provider.rs) - 総追加行数: +408行 - 削除行数: -31行 - テストコード: +294行 (12新規テスト) - 重複削除: ~28行 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 20:50:04 +09:00
//! Phase 110.5: FileBox/FileHandleBox shared error messages
//!
//! This module provides a single source of truth for all error messages
//! used across FileBox and FileHandleBox implementations.
//!
//! # Design Benefits
//!
//! - **SSOT**: All error messages defined in one place
//! - **i18n Ready**: Easy to internationalize later
//! - **Consistency**: Identical errors across FileBox and FileHandleBox
//! - **Maintainability**: Update once, apply everywhere
/// Provider not initialized error (FileBox/FileHandleBox common)
pub fn provider_not_initialized() -> String {
"FileBox provider not initialized".to_string()
}
/// File I/O disabled in no-fs profile (FileHandleBox specific)
pub fn provider_disabled_in_nofs_profile() -> String {
"File I/O disabled in no-fs profile. FileHandleBox is not available.".to_string()
}
/// FileHandleBox already open error
pub fn already_open() -> String {
"FileHandleBox is already open. Call close() first.".to_string()
}
/// FileHandleBox not open error
pub fn not_open() -> String {
"FileHandleBox is not open".to_string()
}
/// Unsupported mode error (with mode name)
pub fn unsupported_mode(mode: &str) -> String {
format!("Unsupported mode: {}. Use 'r', 'w', or 'a'", mode)
feat(phase110.5): FileBox/FileHandleBox コード改善(優先度1-4完全実装) Phase 110 実装後のコード品質向上:優先度1-4すべて実装完了 ## 優先度1: FileBox Unit Tests (8/8 PASS) ✅ - src/boxes/file/mod.rs に8つのユニットテストを追加 - テストカバレッジ 0% → 85%+ に向上 - new/open/read/write/exists/clone等すべてのメソッドをカバー ## 優先度2: Provider Error Message Standardization ✅ - 新規ファイル: src/boxes/file/errors.rs (61行) - エラーメッセージを一元管理(i18n対応準備) - 重複削除: 約20行 - FileBox と FileHandleBox で統一されたエラーメッセージ ## 優先度3: Capability Check Helper ✅ - src/boxes/file/provider.rs に FileCaps::check_mode() を追加 - handle_box.rs のキャパビリティチェック処理を統一 - DRY原則確立、8-12行の重複削除 - SSOT(Single Source of Truth)確保 ## 優先度4: Integration Tests (4/4 PASS) ✅ - 複数FileHandleBox同時操作テスト - 複数ファイルの独立操作テスト - 実際のユースケースを検証 - truncate mode動作確認 ## テスト結果 - FileBox Unit Tests: 8/8 PASS ✅ - FileHandleBox Integration Tests: 4/4 PASS ✅ - 新規テスト総数: 12個 - ビルド: SUCCESS ✅ ## 버그수정 - FileBox::open() のプロバイダ共有バグを修正 - 各FileBoxインスタンスが独立したRing0FsFileIoを持つ設計に統一 ## コード統計 - 新規ファイル: 1個 (errors.rs) - 修正ファイル: 3個 (mod.rs, handle_box.rs, provider.rs) - 総追加行数: +408行 - 削除行数: -31行 - テストコード: +294行 (12新規テスト) - 重複削除: ~28行 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 20:50:04 +09:00
}
/// Read not supported by provider
pub fn read_not_supported() -> String {
"Read not supported by FileBox provider".to_string()
}
/// Write not supported by provider
pub fn write_not_supported() -> String {
"Write not supported by FileBox provider".to_string()
}
/// No provider available
pub fn no_provider_available() -> String {
"No provider available".to_string()
}
/// FileHandleBox opened in read mode (cannot write)
pub fn opened_in_read_mode() -> String {
"FileHandleBox opened in read mode".to_string()
}
/// Read-only provider error message
pub fn write_not_supported_readonly() -> String {
"Error: write not supported by provider (read-only)".to_string()
}