1 // This Source Code Form is subject to the terms of the Mozilla Public
2 // License, v. 2.0. If a copy of the MPL was not distributed with this
3 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 nsresult, NS_ERROR_ILLEGAL_VALUE, NS_ERROR_INVALID_ARG, NS_ERROR_LAUNCHED_CHILD_PROCESS,
10 NS_ERROR_NOT_AVAILABLE,
14 #[derive(Debug, Error)]
15 pub enum RemoteAgentError {
16 #[error("expected address syntax [<host>]:<port>: {0}")]
17 AddressSpec(#[from] http::uri::InvalidUri),
19 #[error("may only be instantiated in parent process")]
22 #[error("invalid port: {0}")]
23 InvalidPort(#[from] num::ParseIntError),
25 #[error("listener restricted to loopback devices")]
28 #[error("missing port number")]
31 #[error("unavailable")]
34 #[error("error result {0}")]
35 XpCom(#[source] nsresult),
38 impl From<RemoteAgentError> for nsresult {
39 fn from(err: RemoteAgentError) -> nsresult {
40 use RemoteAgentError::*;
42 AddressSpec(_) | InvalidPort(_) => NS_ERROR_INVALID_ARG,
43 ChildProcess => NS_ERROR_LAUNCHED_CHILD_PROCESS,
44 LoopbackRestricted => NS_ERROR_ILLEGAL_VALUE,
45 MissingPort => NS_ERROR_INVALID_ARG,
46 Unavailable => NS_ERROR_NOT_AVAILABLE,
47 XpCom(result) => result,
52 impl From<nsresult> for RemoteAgentError {
53 fn from(result: nsresult) -> Self {
54 use RemoteAgentError::*;
56 NS_ERROR_NOT_AVAILABLE => Unavailable,
57 NS_ERROR_LAUNCHED_CHILD_PROCESS => ChildProcess,
58 x => RemoteAgentError::XpCom(x),