Skip to main content

robius_open/
error.rs

1pub type Result<T> = std::result::Result<T, Error>;
2
3/// Errors encountered when opening a URI.
4#[derive(Debug)]
5pub enum Error {
6    /// Could not acquire the android environment.
7    ///
8    /// See the `robius-android-env` crate for more details.
9    AndroidEnvironment,
10    #[cfg(target_os = "android")]
11    Java(jni::errors::Error),
12    /// The provided URI was malformed or otherwise invalid.
13    MalformedUri,
14    /// No handler was available to open the URI.
15    NoHandler,
16    /// The URI was not opened because it must be called on the main UI thread.
17    NotMainThread,
18    /// An unknown error occurred.
19    ///
20    /// Note that on certain platforms if a handler is not available this error
21    /// variant will be returned, as the error returned by the operating system
22    /// is not fine-grained enough.
23    Unknown,
24}
25
26#[cfg(target_os = "android")]
27impl From<jni::errors::Error> for Error {
28    fn from(value: jni::errors::Error) -> Self {
29        Self::Java(value)
30    }
31}