diff options
| author | Dmitry Vdovin | 2017-09-21 10:40:41 +0200 |
|---|---|---|
| committer | Dmitry Vdovin | 2017-09-28 16:06:58 +0200 |
| commit | e9e22536bca048216c3c57196a4c2c1352b30e68 (patch) | |
| tree | d86dea4763b645b770a693194f7f887577c5d661 | |
| parent | 4d7138e040cd5faaf84448a75b64f3ff0e4673e5 (diff) | |
| download | validator-e9e22536bca048216c3c57196a4c2c1352b30e68.tar.bz2 | |
[#29] Implement Error and Display for ValidationErrors
| -rw-r--r-- | validator/src/types.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/validator/src/types.rs b/validator/src/types.rs index bb176c3..5c62e6d 100644 --- a/validator/src/types.rs +++ b/validator/src/types.rs @@ -59,3 +59,14 @@ impl ValidationErrors { self.0.is_empty() } } + +impl std::error::Error for ValidationErrors { + fn description(&self) -> &str { "Validation failed" } + fn cause(&self) -> Option<&std::error::Error> { None } +} + +impl fmt::Display for ValidationErrors { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(self, fmt) + } +} |
