xref: /webrtc/constraints/src/errors.rs (revision c02a612a)
1 //! Errors, as defined in the ["Media Capture and Streams"][mediacapture_streams] spec.
2 //!
3 //! [mediacapture_streams]: https://www.w3.org/TR/mediacapture-streams/
4 
5 #[derive(Clone, Default, Eq, PartialEq, Debug)]
6 pub struct OverconstrainedError {
7     /// The offending constraint's name.
8     pub constraint: String,
9     /// Error message.
10     pub message: Option<String>,
11 }
12 
13 impl std::fmt::Display for OverconstrainedError {
14     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15         write!(f, "Overconstrained property {:?}", self.constraint)?;
16         if let Some(message) = self.message.as_ref() {
17             write!(f, ": {}", message)?;
18         }
19         Ok(())
20     }
21 }
22 
23 impl std::error::Error for OverconstrainedError {}
24