rust_unique_pass/core/app_errors.rs
1/* Copyright 2024-2025 Neuron Grid
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 https://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License. */
14
15use std::io;
16use thiserror::Error;
17
18/// # Overview
19/// パスワード生成プロセス中に発生しうるエラーを定義します。
20#[derive(Error, Debug)]
21pub enum GenerationError {
22 /// パスワード長が不正な場合に発生します。
23 #[error("Invalid password length")]
24 InvalidLength,
25 /// パスワード生成が指定された試行回数内に完了しなかった場合に発生します。
26 #[error("Password generation failed")]
27 GenerationFailed,
28 /// パスワード生成に使用する文字セットが何も選択されなかった場合に発生します。
29 #[error("No character set selected")]
30 NoCharacterSet,
31 /// 指定された翻訳キーに対応する翻訳が見つからなかった場合に発生します。
32 #[error("Translation missing: {0}")]
33 TranslationMissing(String),
34 /// 標準入出力操作中にエラーが発生した場合に発生します。
35 #[error("IO error: {0}")]
36 IoError(#[from] io::Error),
37 /// 指定された言語がサポートされていない場合に発生します。
38 #[error("Unsupported language")]
39 UnsupportedLanguage,
40 /// 翻訳リソースのパースに失敗した場合に発生します。
41 #[error("Resource parse error")]
42 ResourceParseError,
43 /// ユーザーとの対話がキャンセルされたか、無効な入力があった場合に発生します。
44 #[error("Interaction cancelled or invalid input.")]
45 InvalidInput,
46}
47
48/// # Overview
49/// アプリケーション全体で使用される [`Result`] 型のエイリアス。
50/// エラー型として [`GenerationError`] を使用します。
51pub type Result<T> = std::result::Result<T, GenerationError>;