From cf43e2a5733f574e9e68b3046b8285c41a8d66a1 Mon Sep 17 00:00:00 2001 From: Martin Kustermann Date: Mon, 23 Jun 2025 05:53:09 -0700 Subject: [PATCH] [dart2wasm] Throw UnsupportedError instead of string in IndexError.* getters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a follow-up to [0]. [0] https://dart-review.googlesource.com/c/sdk/+/435783B Change-Id: I18e85980a782ae851edd265da0d451f131e594c0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436282 Reviewed-by: Lasse Nielsen Commit-Queue: Martin Kustermann Reviewed-by: Ömer Ağacan --- sdk/lib/_internal/wasm/lib/error_utils.dart | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/sdk/lib/_internal/wasm/lib/error_utils.dart b/sdk/lib/_internal/wasm/lib/error_utils.dart index 8e1dc1d35a8..20828ea0db0 100644 --- a/sdk/lib/_internal/wasm/lib/error_utils.dart +++ b/sdk/lib/_internal/wasm/lib/error_utils.dart @@ -258,6 +258,8 @@ const _reachabilityError = _LateErrorWithoutDetails( const _noSuchMethodErrorWithoutDetails = _NoSuchMethodErrorWithoutDetails(); +const _unsupportedErrorWithoutDetails = _UnsupportedErrorWithoutDetails(); + const typeErrorWithoutDetails = _TypeErrorWithoutDetails(); class _ErrorWithoutDetails implements Error { @@ -278,7 +280,7 @@ class _ArgumentErrorWithoutDetails extends _ErrorWithoutDetails String? get name => null; @override - String get message => toString(); + String get message => _message; @override dynamic get invalidValue => null; @@ -290,16 +292,16 @@ class _IndexErrorWithoutDetails extends _ArgumentErrorWithoutDetails : super('IndexError (details omitted due to --minify)'); @override - int get start => throw 'no details'; + int get start => throw _unsupportedErrorWithoutDetails; @override - int get end => throw 'no details'; + int get end => throw _unsupportedErrorWithoutDetails; @override - int get length => throw 'no details'; + int get length => throw _unsupportedErrorWithoutDetails; @override - int get invalidValue => throw 'no details'; + int get invalidValue => throw _unsupportedErrorWithoutDetails; @override Object? get indexable => null; @@ -335,3 +337,12 @@ class _LateErrorWithoutDetails extends _ErrorWithoutDetails implements LateError { const _LateErrorWithoutDetails(String message) : super(message); } + +class _UnsupportedErrorWithoutDetails extends _ErrorWithoutDetails + implements UnsupportedError { + const _UnsupportedErrorWithoutDetails() + : super('UnsupportedError (details omitted due to --minify)'); + + @override + String get message => _message; +}