fix: Replace unwrap with expect for better logging
This commit is contained in:
parent
abfdea2e78
commit
ea07d11034
@ -108,8 +108,12 @@ async fn main() {
|
|||||||
|
|
||||||
let socket = SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), state.config.port);
|
let socket = SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), state.config.port);
|
||||||
info!("Serving Karnaugh on socket {}", socket);
|
info!("Serving Karnaugh on socket {}", socket);
|
||||||
let listener = tokio::net::TcpListener::bind(socket).await.unwrap();
|
let listener = tokio::net::TcpListener::bind(socket)
|
||||||
axum::serve(listener, app).await.unwrap();
|
.await
|
||||||
|
.expect(&format!("Failed to bind to socket {}", socket));
|
||||||
|
axum::serve(listener, app)
|
||||||
|
.await
|
||||||
|
.expect("Failed to serve site");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn root_handler(State(state): State<AppState>) -> impl IntoResponse {
|
async fn root_handler(State(state): State<AppState>) -> impl IntoResponse {
|
||||||
|
|||||||
@ -138,7 +138,10 @@ impl<'a> DocumentWorld<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_package(&self, spec: &PackageSpec) -> PackageResult<PathBuf> {
|
fn get_package(&self, spec: &PackageSpec) -> PackageResult<PathBuf> {
|
||||||
let path = get_package_path(&VirtualPath::new("").unwrap(), spec);
|
let path = get_package_path(
|
||||||
|
&VirtualPath::new("").expect("Failed to create empty virtual path"),
|
||||||
|
spec,
|
||||||
|
);
|
||||||
let path = path.realize(&self.context.config.packages_root);
|
let path = path.realize(&self.context.config.packages_root);
|
||||||
|
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
@ -177,6 +180,9 @@ impl<'a> DocumentWorld<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_package_path(file_path: &VirtualPath, spec: &PackageSpec) -> VirtualPath {
|
fn get_package_path(file_path: &VirtualPath, spec: &PackageSpec) -> VirtualPath {
|
||||||
let package_path = VirtualPath::new(format!("{}/{}", spec.name, spec.version)).unwrap();
|
let package_path = VirtualPath::new(format!("{}/{}", spec.name, spec.version))
|
||||||
package_path.join(file_path.get_without_slash()).unwrap()
|
.expect("Failed to create virtual path representing package path.");
|
||||||
|
package_path
|
||||||
|
.join(file_path.get_without_slash())
|
||||||
|
.expect("Failed to join file path into package path.")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user