Skip to content

Commit

Permalink
fix: handle error type declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
zeropaper committed Sep 21, 2021
1 parent f52e04c commit e8f6e90
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/layers/ThreeJS/ThreeJSLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class ThreeJSLayer extends Layer {
try {
this.camera.aspect = this.width / this.height;
} catch (e) {
console.info('[ThreeJS] cannot set aspect', e.message);
console.info('[ThreeJS] cannot set aspect', (e as Error).message);
}
};

Expand Down
10 changes: 6 additions & 4 deletions src/utils/ScriptRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,13 @@ class ScriptRunner {
this.#version += 1;
}
} catch (error) {
this.#errors.compilation = error;
const err = error as ScriptRunnerCodeError;
this.#errors.compilation = err;
this.dispatchEvent({
type: 'compilationerror',
error,
lineNumber: error.lineNumber || 0,
columnNumber: error.columnNumber || 0,
lineNumber: err.lineNumber || 0,
columnNumber: err.columnNumber || 0,
code,
builderStr,
} as ScriptRunnerErrorEvent);
Expand Down Expand Up @@ -241,7 +242,8 @@ class ScriptRunner {
/* istanbul ignore next */
return result instanceof EmptyScope ? undefined : result;
} catch (error) {
this.#errors.execution = error;
const err = error as ScriptRunnerCodeError;
this.#errors.execution = err;
this.dispatchEvent({
type: 'executionerror',
error,
Expand Down
24 changes: 24 additions & 0 deletions src/utils/VFS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function writeFile(vfsPath: string, content: string) {
//
}

export default class VFS {
#tmppath = '';

#files: { [vfsPath: string]: string };

add(vfsPath: string, content: string) {
this.#files[vfsPath] = this.#files[vfsPath]
? `${this.#files[vfsPath]}${content}`
: content;
}

async write() {
return Promise.all(Object.keys(this.#files)
.reduce((promises: Promise<any>[], key) => [
...promises,
writeFile(key, this.#files[key]),
], []));
}
}

0 comments on commit e8f6e90

Please sign in to comment.