Skip to content

Commit e19e1ac

Browse files
Desktop: OneNote importer: Simplify error report (#14074)
1 parent 6d7a70c commit e19e1ac

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

packages/app-desktop/gui/WindowCommandsAndDialogs/commands/importFrom.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ export const runtime = (control: WindowControl): CommandRuntime => {
124124

125125
void CommandService.instance().execute('showModalMessage', `${modalMessage}\n\n${statusStrings.join('\n')}`);
126126
},
127-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
128-
onError: (error: any) => {
127+
onError: (error: string|Error) => {
129128
errors.push(error);
130129
console.warn(error);
131130
},

packages/lib/services/interop/InteropService_Importer_OneNote.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ export default class InteropService_Importer_OneNote extends InteropService_Impo
110110
try {
111111
await oneNoteConverter(notebookFilePath, resolve(outputDirectory2), notebookBaseDir);
112112
} catch (error) {
113-
this.options_.onError?.(error);
113+
// Forward only the error message. Usually the stack trace points to bytes in the WASM file.
114+
// It's very difficult to use and can cause the error report to be longer than the maximum
115+
// length for auto-creating a forum post:
116+
this.options_.onError?.(error.message ?? error);
114117
console.error(error);
115118
}
116119
}

packages/onenote-converter/renderer/src/section.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ pub(crate) struct RenderedSection {
1616
pub(crate) section_dir: String,
1717
}
1818

19+
const ERRORS_NOTE_NAME: &str = "⚠️ Errors ⚠️";
20+
1921
impl Renderer {
2022
pub fn new() -> Self {
2123
Renderer {
@@ -81,11 +83,11 @@ impl Renderer {
8183
let toc_path = self.write_html_file(&output_dir, section.display_name(), &toc_html)?;
8284
log!("ToC: {}", toc_path);
8385

84-
if let Some(errors_path) = errors_path {
86+
if errors_path.is_some() {
8587
Err(ErrorKind::RenderFailed(format!(
8688
"Some pages failed to render. First error: {:?}. Full error report written to {}",
8789
errors.first(),
88-
errors_path
90+
ERRORS_NOTE_NAME,
8991
))
9092
.into())
9193
} else {
@@ -136,7 +138,7 @@ impl Renderer {
136138
Ok(TocEntry {
137139
level: 1,
138140
is_error: true,
139-
name: "⚠️ Errors ⚠️".into(),
141+
name: ERRORS_NOTE_NAME.into(),
140142
relative_path: fs_driver().remove_prefix(&errors_path, &output_dir).into(),
141143
})
142144
}

0 commit comments

Comments
 (0)