Make the file property optional #95

Merged
merged 1 commit into from Feb 15, 2014

2 participants

@lydell

No description provided.

@fitzgen fitzgen and 1 other commented on an outdated diff Feb 14, 2014
lib/source-map/source-map-generator.js
*/
SourceMapGenerator.prototype.applySourceMap =
function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile) {
// If aSourceFile is omitted, we will use the file property of the SourceMap
if (!aSourceFile) {
+ if (!aSourceMapConsumer.file) {
+ throw new Error(
+ 'Tried to fall back on the file property of the source map ' +
+ 'to apply (since the second argument was omitted), but it ' +
+ 'was not set.'
+ );
@fitzgen
Mozilla member
fitzgen added a line comment Feb 14, 2014

How about something like

throw new Error(
  'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
  'or the source map\'s "file" property. Both were omitted.'
);
@lydell
lydell added a line comment Feb 14, 2014

Yeah, that sounds better. But really I'd like to deprecate omitting the second parameter. How can we warn users? console.warn? Or is that a separate pull request?

@fitzgen
Mozilla member
fitzgen added a line comment Feb 14, 2014

File an issue first to open discussion. My reaction at this moment in time is that nothing needs to be deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fitzgen
Mozilla member

Looks good, will merge once the error message is a little more clear, as mentioned above.

@lydell

I've amended your improved error message now.

@fitzgen fitzgen merged commit 9315f02 into mozilla:master Feb 15, 2014

1 check passed

Details default The Travis CI build passed
@fitzgen
Mozilla member

Thanks!

@lydell lydell deleted the lydell:optional-file branch Jun 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment