Skip to content

Commit 01c18a7

Browse files
committed
feat: Display Rant errors in output directly, disable require function (module loading does not work anyway)
1 parent c1ff9e9 commit 01c18a7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/lib.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt;
22

3-
use rant::{compiler::CompilerErrorKind, runtime::RuntimeError, Rant, RantValue};
3+
use rant::{compiler::CompilerErrorKind, runtime::RuntimeError, Rant, RantOptions, RantValue};
44
use wasm_bindgen::prelude::*;
55

66
#[wasm_bindgen]
@@ -12,7 +12,12 @@ pub fn rant(input: &str, seed: u32) -> Result<String, JsValue> {
1212
}
1313

1414
fn _rant(input: &str, seed: u32) -> Result<RantValue, RantError> {
15-
let mut rant = Rant::with_seed(seed as u64);
15+
let options = RantOptions {
16+
seed: seed.into(),
17+
enable_require: false,
18+
..Default::default()
19+
};
20+
let mut rant = Rant::with_options(options);
1621
let program = rant.compile_quiet(input).map_err(RantError::Compiler)?;
1722
rant.run(&program).map_err(RantError::Runtime)
1823
}

src/processor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export abstract class BaseRantProcessor extends MarkdownRenderChild {
2626
try {
2727
this.result = rant(input, seed);
2828
} catch (error) {
29-
this.result = "ERROR processing Rant block (see console for details)";
29+
this.result = error;
3030
console.error(error);
3131
}
3232
}

0 commit comments

Comments
 (0)