Skip to main content

tsoracle_standalone/
error.rs

1//
2//  ░▀█▀░█▀▀░█▀█░█▀▄░█▀█░█▀▀░█░░░█▀▀
3//  ░░█░░▀▀█░█░█░█▀▄░█▀█░█░░░█░░░█▀▀
4//  ░░▀░░▀▀▀░▀▀▀░▀░▀░▀░▀░▀▀▀░▀▀▀░▀▀▀
5//
6//  tsoracle — Distributed Timestamp Oracle
7//  https://www.tsoracle.rs
8//
9//  Copyright (c) 2026 Prisma Risk
10//
11//  Licensed under the Apache License, Version 2.0 (the "License");
12//  you may not use this file except in compliance with the License.
13//  You may obtain a copy of the License at
14//
15//      https://www.apache.org/licenses/LICENSE-2.0
16//
17//  Unless required by applicable law or agreed to in writing, software
18//  distributed under the License is distributed on an "AS IS" BASIS,
19//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20//  See the License for the specific language governing permissions and
21//  limitations under the License.
22//
23
24use std::net::SocketAddr;
25use std::path::PathBuf;
26
27/// Failure modes when bootstrapping a standalone node.
28#[derive(Debug, thiserror::Error)]
29pub enum StandaloneError {
30    #[error("failed to open storage at {path}: {source}")]
31    Storage {
32        path: PathBuf,
33        #[source]
34        source: Box<dyn std::error::Error + Send + Sync>,
35    },
36    #[error("failed to bind peer transport on {addr}: {source}")]
37    PeerBind {
38        addr: SocketAddr,
39        #[source]
40        source: std::io::Error,
41    },
42    #[error("failed to bind admin server on {addr}: {source}")]
43    AdminBind {
44        addr: SocketAddr,
45        #[source]
46        source: std::io::Error,
47    },
48    #[error(
49        "admin listener on {addr} requires --admin-tls-{{cert,key,ca}} \
50         (only loopback addresses may bind without admin TLS)"
51    )]
52    AdminInsecureRoutable { addr: SocketAddr },
53    #[error(
54        "peer listener on {addr} requires --peer-tls-{{cert,key,ca}} or \
55         --allow-insecure-peer (only loopback addresses may bind without peer TLS)"
56    )]
57    PeerInsecureRoutable { addr: SocketAddr },
58    #[error("driver bootstrap failed: {0}")]
59    Bootstrap(Box<dyn std::error::Error + Send + Sync>),
60    #[error("invalid configuration: {0}")]
61    Config(String),
62    #[error("failed to load TLS material from {path}: {source}")]
63    Tls {
64        path: std::path::PathBuf,
65        #[source]
66        source: Box<dyn std::error::Error + Send + Sync>,
67    },
68}