Skip to content

Commit

Permalink
throw error when unexpected state has been found
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed May 27, 2018
1 parent 115a72c commit 7ebe12d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/RuntimeTemplate.js
Expand Up @@ -65,10 +65,16 @@ module.exports = class RuntimeTemplate {
}

moduleId({ module, request }) {
if (!module)
if (!module) {
return this.missingModule({
request
});
}
if (module.id === null) {
throw new Error(
`RuntimeTemplate.moduleId(): Module ${module.identifier()} has no id. This should not happen.`
);
}
return `${this.comment({ request })}${JSON.stringify(module.id)}`;
}

Expand Down Expand Up @@ -105,10 +111,16 @@ module.exports = class RuntimeTemplate {
}

moduleNamespacePromise({ block, module, request, message, strict, weak }) {
if (!module)
if (!module) {
return this.missingModulePromise({
request
});
}
if (module.id === null) {
throw new Error(
`RuntimeTemplate.moduleNamespacePromise(): Module ${module.identifier()} has no id. This should not happen.`
);
}
const promise = this.blockPromise({
block,
message
Expand Down Expand Up @@ -151,10 +163,16 @@ module.exports = class RuntimeTemplate {
}

importStatement({ update, module, request, importVar, originModule }) {
if (!module)
if (!module) {
return this.missingModuleStatement({
request
});
}
if (module.id === null) {
throw new Error(
`RuntimeTemplate.importStatement(): Module ${module.identifier()} has no id. This should not happen.`
);
}
const comment = this.comment({
request
});
Expand Down

0 comments on commit 7ebe12d

Please sign in to comment.