-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #347 from ezioleq/NE-242
Change thrown exception type in Window's class constructor
- Loading branch information
Showing
6 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use std::{error::Error, fmt::Display}; | ||
|
||
use crate::interop::prelude::{ResultError, ResultErrorKind}; | ||
|
||
#[derive(Debug)] | ||
pub struct PlatformNotSupportedError { | ||
message: String, | ||
} | ||
|
||
impl PlatformNotSupportedError { | ||
pub fn new(message: String) -> Self { | ||
Self { message } | ||
} | ||
|
||
pub fn with_str(message: &str) -> Self { | ||
Self::new(message.to_owned()) | ||
} | ||
} | ||
|
||
impl Default for PlatformNotSupportedError { | ||
fn default() -> Self { | ||
Self { | ||
message: "Platform not supported.".to_string(), | ||
} | ||
} | ||
} | ||
|
||
impl Error for PlatformNotSupportedError { | ||
fn source(&self) -> Option<&(dyn Error + 'static)> { | ||
None | ||
} | ||
} | ||
|
||
impl Display for PlatformNotSupportedError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", self.message) | ||
} | ||
} | ||
|
||
impl From<PlatformNotSupportedError> for ResultError { | ||
fn from(err: PlatformNotSupportedError) -> Self { | ||
ResultError::with_kind(&err, ResultErrorKind::PlatformNotSupported) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters