Skip to content

Commit

Permalink
Polyfill: Improve error message
Browse files Browse the repository at this point in the history
This error message wasn't taking string time zone slot values into
account, which are the most common case. We can make the error message
more specific for this case.
  • Loading branch information
ptomato authored and Ms2ger committed Feb 26, 2024
1 parent f71cca6 commit 2ff1ed3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,9 @@ export function InterpretISODateTimeOffset(
const offsetStr = FormatUTCOffsetNanoseconds(offsetNs);
const timeZoneString = IsTemporalTimeZone(timeZoneRec.receiver)
? GetSlot(timeZoneRec.receiver, TIMEZONE_ID)
: 'time zone';
: typeof timeZoneRec.receiver === 'string'
? timeZoneRec.receiver
: 'time zone';
throw new RangeError(`Offset ${offsetStr} is invalid for ${dt} in ${timeZoneString}`);
}
// fall through: offsetOpt === 'prefer', but the offset doesn't match
Expand Down

0 comments on commit 2ff1ed3

Please sign in to comment.