From 5a5bf24ee3d6a685c628592d91d2548da633a960 Mon Sep 17 00:00:00 2001 From: Mustafa Senoglu Date: Sun, 5 Jul 2026 14:38:47 +0300 Subject: [PATCH] Add console.exception() as alias for console.error() WHATWG Console specification defines console.exception() as identical to console.error(). This adds the alias registration in Console::make_console() and a test to verify it works. Closes #307 --- core/runtime/src/console/mod.rs | 5 +++++ core/runtime/src/console/tests.rs | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/core/runtime/src/console/mod.rs b/core/runtime/src/console/mod.rs index 8bb4b3b892b..aa7fa9d2194 100644 --- a/core/runtime/src/console/mod.rs +++ b/core/runtime/src/console/mod.rs @@ -396,6 +396,11 @@ impl Console { js_string!("error"), 0, ) + .function( + console_method(Self::error, state.clone(), logger.clone()), + js_string!("exception"), + 0, + ) .function( console_method(Self::info, state.clone(), logger.clone()), js_string!("info"), diff --git a/core/runtime/src/console/tests.rs b/core/runtime/src/console/tests.rs index 6ff1de47430..4205e01263c 100644 --- a/core/runtime/src/console/tests.rs +++ b/core/runtime/src/console/tests.rs @@ -841,6 +841,26 @@ fn console_table_map_ignores_properties_filter() { assert!(logs.contains("Values")); } +/// exception should be an alias for error. +#[test] +fn console_exception_is_alias_for_error() { + let mut context = Context::default(); + let logger = RecordingLogger::default(); + Console::register_with_logger(logger.clone(), &mut context).unwrap(); + + run_test_actions_with( + [ + TestAction::run(indoc! {r#" + console.exception("hello world"); + "#}), + ], + &mut context, + ); + + let logs = logger.log.borrow().clone(); + assert_eq!(logs, "hello world\n"); +} + /// Set should ignore the properties filter and keep its fixed column layout. #[test] fn console_table_set_ignores_properties_filter() {