Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Issue 920793002: Change _interpolateSingle to use the same value in errors as _interpolate. (Closed)

Created:
5 years, 10 months ago by Lasse Reichstein Nielsen
Modified:
5 years, 10 months ago
Reviewers:
iposva, sra1, Ivan Posva
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Change _interpolateSingle to use the same value in errors as _interpolate. R=iposva@google.com Committed: https://code.google.com/p/dart/source/detail?r=43942

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+1 line, -1 line) Patch
M runtime/lib/string_patch.dart View 1 chunk +1 line, -1 line 3 comments Download

Messages

Total messages: 7 (3 generated)
Lasse Reichstein Nielsen
https://codereview.chromium.org/920793002/diff/1/runtime/lib/string_patch.dart File runtime/lib/string_patch.dart (right): https://codereview.chromium.org/920793002/diff/1/runtime/lib/string_patch.dart#newcode802 runtime/lib/string_patch.dart:802: throw new ArgumentError(s); Using "o", which we already know ...
5 years, 10 months ago (2015-02-12 13:11:10 UTC) #2
Ivan Posva
LGTM for consistency, but we should really switch to using safeToString. -Ivan https://codereview.chromium.org/920793002/diff/1/runtime/lib/string_patch.dart File runtime/lib/string_patch.dart ...
5 years, 10 months ago (2015-02-20 06:43:48 UTC) #4
Lasse Reichstein Nielsen
Committed patchset #1 (id:1) manually as 43942 (presubmit successful).
5 years, 10 months ago (2015-02-23 08:10:15 UTC) #5
sra1
5 years, 10 months ago (2015-02-24 16:57:02 UTC) #7
Message was sent while issue was closed.
https://codereview.chromium.org/920793002/diff/1/runtime/lib/string_patch.dart
File runtime/lib/string_patch.dart (right):

https://codereview.chromium.org/920793002/diff/1/runtime/lib/string_patch.dar...
runtime/lib/string_patch.dart:802: throw new ArgumentError(s);
On 2015/02/12 13:11:09, Lasse Reichstein Nielsen wrote:
> Using "o", which we already know has a faulty toString, means that the error
> can't be printed either. We used "s" in _interpolate below.
> 
> Using "s" reduces the problem (but using Error.safeToString(s)) would likely
be
> even better.

It seems a bad idea to report the wrong irritant like this (e.g. null).

We would not worry about this if ArgumentError was robust and reported a bad
object for the 'message' , e.g.  "Instance of ${o.runtimeType} (with bad
toString() method)", or "unprintable object" if that fails too.

That would also help other places that throw errors with bad toString methods.

We could still report something special here.

If this throw was changed to

   throw _interpolationNotStringError(o, s);

then the helper could be called from _interpolate too to ensure consistency,
probably throwing something like ArgumentError.value(o, 'interpolated value',
'toString() method does not return a String')

Powered by Google App Engine
This is Rietveld 408576698