Skip to content

Commit 1d04468

Browse files
Show full anyhow error messages
1 parent 7cb4f44 commit 1d04468

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src-native/data.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use crate::library::{Paths, load_old_library_json, open_library};
22
use crate::library_types::Library;
33
use crate::tracks::Tag;
4-
use anyhow::{Context, Result};
4+
use anyhow::Context;
55
use atomicwrites::{AllowOverwrite, AtomicFile};
66
use dirs_next;
7+
use napi::Result;
78
use serde::Serialize;
89
use sqlx::SqliteConnection;
910
use std::env;

src-native/data_js.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
use crate::data::{Data, app_log_dir, path_to_string};
22
use crate::library::Paths;
3-
use anyhow::Result;
4-
use napi::Env;
3+
use napi::{Env, Result};
54
use std::fs;
65

6+
pub struct JsError(pub anyhow::Error);
7+
8+
impl From<JsError> for napi::Error {
9+
fn from(err: JsError) -> Self {
10+
napi::Error::from_reason(format!("{:#}", err.0))
11+
}
12+
}
13+
impl From<anyhow::Error> for JsError {
14+
fn from(err: anyhow::Error) -> Self {
15+
JsError(err)
16+
}
17+
}
18+
719
pub fn get_data(env: &Env) -> &mut Data {
820
let data = env
921
.get_instance_data::<Data>()

0 commit comments

Comments
 (0)