1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use thiserror::Error;
/// Errors raised while serving an application's workspaces.
#[derive(Debug, Error)]
pub enum Error {
/// Opening or using a workspace failed.
#[error(transparent)]
Workspace(#[from] sapphire_workspace::Error),
/// A backend operation failed.
#[error(transparent)]
Backend(#[from] sapphire_backend::Error),
/// The IPC layer failed.
#[error(transparent)]
Ipc(#[from] sapphire_ipc::Error),
/// Finding, verifying or installing a release failed.
#[error(transparent)]
Update(#[from] sapphire_framework_update::Error),
/// Listening, or preparing the runtime directory, failed.
#[error(transparent)]
Io(#[from] std::io::Error),
/// The request named a directory that is not a workspace of this application.
#[error("{0} is not a {1} workspace")]
UnknownWorkspace(std::path::PathBuf, &'static str),
/// The server has no workspace yet, or the one asked for is no longer current (#215).
#[error(
"this server has no workspace yet; run `workspace init <dir>` or `workspace select <dir>`"
)]
NoWorkspace,
/// The workgroup has no workspace with this name or id.
#[error("the workgroup has no workspace {0}")]
UnknownWorkspaceName(String),
/// The workgroup workspace belongs to another application.
#[error("workspace {name} belongs to {app_name}, not this application")]
WrongApp {
/// The workspace's name.
name: String,
/// The application that owns it.
app_name: String,
},
/// A workspace's sync identity could not be read or written.
///
/// Never repaired by minting a new identity: the workspace may already exist on
/// another device, and a second identity would make the two sync as unrelated
/// workspaces for ever.
#[error("{0}")]
SyncId(String),
/// The replication core failed.
///
/// Carries its error's `Display`, not the error: the core's own type is an internal
/// detail, while the message is what status and the logs need.
#[error("replication failed: {0}")]
Sync(String),
/// The bridge refused a request, or could not be reached.
///
/// Not fatal to the app server: the bridge carries replication, and everything the
/// application itself does works without it (spec ยง10).
#[error("the bridge could not be reached: {0}")]
Bridge(String),
/// The server has no connection to the bridge right now: it was not running when the
/// server started, or it stopped since. The server reconnects on its own (#244).
#[error(
"not connected to sapphire-bridge; this server reconnects on its own once the bridge is running"
)]
BridgeDisconnected,
/// A replication session failed.
#[error(transparent)]
Session(#[from] sapphire_framework_session::Error),
/// A configuration file that could not be read or written as expected.
#[error("{0}")]
Config(String),
/// The MCP session on stdio could not start or ended abnormally.
#[error("{0}")]
Mcp(String),
/// Installing, removing or reporting this application's service failed.
///
/// Carries the service crate's own message, which already says what to do about the
/// case at hand, or which platform offers what.
#[error(transparent)]
Service(#[from] sapphire_framework_service::Error),
}
/// Convenience alias for server results.
pub type Result<T> = std::result::Result<T, Error>;