diff options
| author | 2025-09-12 04:02:02 +0800 | |
|---|---|---|
| committer | 2025-09-12 04:02:02 +0800 | |
| commit | 0288d0956330d5ac8db48b752240f723e8703929 (patch) | |
| tree | 0297dee9f8166af0a856dd3a1057ad5f25f14c6a /src/errors.rs | |
| parent | 5135876b5e2a6c40232414ea0b7eb875fa225cf0 (diff) | |
| download | OneRoll-0288d0956330d5ac8db48b752240f723e8703929.tar.gz OneRoll-0288d0956330d5ac8db48b752240f723e8703929.zip | |
feat: initial basic roll features
Diffstat (limited to 'src/errors.rs')
| -rw-r--r-- | src/errors.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/errors.rs b/src/errors.rs new file mode 100644 index 0000000..8a20863 --- /dev/null +++ b/src/errors.rs @@ -0,0 +1,17 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum DiceError { + #[error("解析错误: {0}")] + ParseError(String), + #[error("计算错误: {0}")] + CalculationError(String), + #[error("无效的骰子表达式: {0}")] + InvalidExpression(String), +} + +impl std::convert::From<DiceError> for pyo3::PyErr { + fn from(err: DiceError) -> pyo3::PyErr { + pyo3::PyErr::new::<pyo3::exceptions::PyValueError, _>(err.to_string()) + } +} |
