diff --git a/src/common/util.ts b/src/common/util.ts index d8ef62f2..2d40cbc6 100644 --- a/src/common/util.ts +++ b/src/common/util.ts @@ -461,7 +461,7 @@ export function getWithBinary(url:string, success:(text:string|Uint8Array)=>void } else if (oReq.status == 404) { success(null); } else { - throw "Error " + oReq.status + " loading " + url; + throw Error("Error " + oReq.status + " loading " + url); } } oReq.send(null); diff --git a/src/ide/pixeleditor.ts b/src/ide/pixeleditor.ts index 8409712f..b4552bfa 100644 --- a/src/ide/pixeleditor.ts +++ b/src/ide/pixeleditor.ts @@ -442,7 +442,7 @@ export class TextDataNode extends CodeProjectDataNode { } updateLeft() { if (this.right.words.length != this.words.length) - throw "Expected " + this.right.words.length + " bytes; image has " + this.words.length; + throw Error("Expected " + this.right.words.length + " bytes; image has " + this.words.length); this.words = this.right.words; // TODO: reload editors? var datastr = this.text.substring(this.start, this.end); @@ -715,9 +715,9 @@ export class NESNametableConverter extends Compositor { for (var row=0; row> 4) & 0x38) | ((a >> 2) & 0x07); var attr = this.words[attraddr]; var tag = name ^ (attr<<9) ^ 0x80000000; diff --git a/src/ide/project.ts b/src/ide/project.ts index 682d9465..2c33aba3 100644 --- a/src/ide/project.ts +++ b/src/ide/project.ts @@ -245,7 +245,7 @@ export class CodeProject { } sendBuild() { - if (!this.mainpath) throw "need to call setMainFile first"; + if (!this.mainpath) throw Error("need to call setMainFile first"); var maindata = this.getFile(this.mainpath); // if binary blob, just return it as ROM if (maindata instanceof Uint8Array) { diff --git a/src/ide/services.ts b/src/ide/services.ts index 763ef6d8..d8e06cb7 100644 --- a/src/ide/services.ts +++ b/src/ide/services.ts @@ -156,7 +156,7 @@ export class GithubService { return sess.repo.git.trees(subtree.sha).fetch(); } } - throw "Cannot find subtree '" + sess.subtreepath + "' in tree " + tree.sha; + throw Error("Cannot find subtree '" + sess.subtreepath + "' in tree " + tree.sha); } return tree; }) @@ -207,7 +207,7 @@ export class GithubService { if (m) { console.log("platform id: '" + m[1] + "'"); if (sess.platform_id && !sess.platform_id.startsWith(m[1])) - throw "Platform mismatch: Repository is " + m[1] + ", you have " + this.project.platform_id + " selected."; + throw Error("Platform mismatch: Repository is " + m[1] + ", you have " + this.project.platform_id + " selected."); sess.platform_id = m[1]; } // bind to repository @@ -295,7 +295,7 @@ export class GithubService { return this.getGithubHEADTree(ghurl).then( (session) => { sess = session; if (sess.subtreepath) { - throw "Sorry, right now you can only commit files to the root directory of a repository."; + throw Error("Sorry, right now you can only commit files to the root directory of a repository."); } return Promise.all(files.map( (file) => { if (typeof file.data === 'string') { diff --git a/src/machine/sms.ts b/src/machine/sms.ts index f79faf26..4b21297c 100644 --- a/src/machine/sms.ts +++ b/src/machine/sms.ts @@ -191,7 +191,7 @@ export class SMS extends SG1000 { this.romPageMask = (data.length >> 14) - 1; // div $4000 break; default: - throw "Unknown rom size: $" + hex(data.length); + throw Error("Unknown rom size: $" + hex(data.length)); } } //console.log("romPageMask: " + hex(this.romPageMask)); diff --git a/src/platform/vector.ts b/src/platform/vector.ts index a5a572e9..a0abd6a5 100644 --- a/src/platform/vector.ts +++ b/src/platform/vector.ts @@ -122,7 +122,7 @@ var AtariVectorPlatform = function(mainElement) { this.loadROM = function(title, data) { if(data.length != 0x2000) { - throw "ROM length must be == 0x2000"; + throw Error("ROM length must be == 0x2000"); } rom = data.slice(0,0x1800); vecrom = data.slice(0x1800,0x2000); diff --git a/src/platform/verilog.ts b/src/platform/verilog.ts index e30e7ef9..ca0eeb55 100644 --- a/src/platform/verilog.ts +++ b/src/platform/verilog.ts @@ -140,12 +140,12 @@ export function VL_READMEM_W(ishex,width,depth,array_lsb,fnwords,filename,memp,s var strfn = byteArrayToString(barr); // convert to string // parse hex/binary file var strdata = current_project.getFile(strfn) as string; - if (strdata == null) throw "Could not $readmem '" + strfn + "'"; + if (strdata == null) throw Error("Could not $readmem '" + strfn + "'"); var data = strdata.split('\n').filter(s => s !== '').map(s => parseInt(s, ishex ? 16 : 2)); console.log('$readmem', ishex, strfn, data.length); // copy into destination array - if (memp === null) throw "No destination array to $readmem " + strfn; - if (memp.length < data.length) throw "Destination array too small to $readmem " + strfn; + if (memp === null) throw Error("No destination array to $readmem " + strfn); + if (memp.length < data.length) throw Error("Destination array too small to $readmem " + strfn); for (i=0; i { var jsontext = getWorkFileAsString(filename); - if (!jsontext) throw "could not load " + filename; + if (!jsontext) throw Error("could not load " + filename); return JSON.parse(jsontext); }; asm.loadInclude = function(filename) { @@ -2106,7 +2106,7 @@ function executeBuildSteps() { var step = buildsteps.shift(); // get top of array var platform = step.platform; var toolfn = TOOLS[step.tool]; - if (!toolfn) throw "no tool named " + step.tool; + if (!toolfn) throw Error("no tool named " + step.tool); step.params = PLATFORM_PARAMS[getBasePlatform(platform)]; try { step.result = toolfn(step); diff --git a/test/cli/testgithub.js b/test/cli/testgithub.js index 74ae8945..08d6bea1 100644 --- a/test/cli/testgithub.js +++ b/test/cli/testgithub.js @@ -64,7 +64,7 @@ describe('Store', function() { var store = mstore.createNewPersistentStore('_FOO', function(store) { var gh = newGH(store, '_FOO'); gh.importAndPull('https://github.com/pzpinfo/testrepo1557326056720').catch( (e) => { - assert.ok(e.startsWith('Platform mismatch')); + assert.ok(e.message.startsWith('Platform mismatch')); done(); }); }); @@ -145,7 +145,7 @@ describe('Store', function() { gh.commit('https://github.com/brovador/NESnake/tree/master/src', 'test commit', files) .catch( (e) => { console.log(e); - assert.equal(e, 'Sorry, right now you can only commit files to the root directory of a repository.'); + assert.equal(e.message, 'Sorry, right now you can only commit files to the root directory of a repository.'); done(); }); /*.then( (sess) => {