Skip to content

Commit

Permalink
C APIのエラー表示をtracing::error!にする (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
qryxip authored Sep 5, 2023
1 parent 203a75b commit 53601b5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/voicevox_core_c_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ directml = ["voicevox_core/directml"]
[dependencies]
cstr = "0.2.11"
derive-getters.workspace = true
itertools.workspace = true
libc = "0.2.134"
once_cell.workspace = true
serde_json.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
uuid.workspace = true
voicevox_core.workspace = true
Expand Down
10 changes: 7 additions & 3 deletions crates/voicevox_core_c_api/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::fmt::Debug;
use std::{error::Error as _, fmt::Debug, iter};
use voicevox_core::UserDictWord;

use thiserror::Error;
use tracing::error;

use super::*;
use voicevox_core::AccentPhraseModel;
Expand All @@ -13,8 +14,11 @@ pub(crate) fn into_result_code_with_error(result: CApiResult<()>) -> VoicevoxRes
return into_result_code(result);

fn display_error(err: &CApiError) {
eprintln!("Error(Display): {err}");
eprintln!("Error(Debug): {err:#?}");
itertools::chain(
[err.to_string()],
iter::successors(err.source(), |&e| e.source()).map(|e| format!("Caused by: {e}")),
)
.for_each(|msg| error!("{msg}"));
}

fn into_result_code(result: CApiResult<()>) -> VoicevoxResultCode {
Expand Down

0 comments on commit 53601b5

Please sign in to comment.