Skip to content

Commit

Permalink
fix: Add friendly error if canvasElementId missing(#2885)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyoung4242 authored Jan 14, 2024
1 parent 4639bf9 commit 9c46824
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/engine/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,12 @@ O|===|* >________________>\n\

if (options.canvasElementId) {
this._logger.debug('Using Canvas element specified: ' + options.canvasElementId);

//test for existence of element
if (document.getElementById(options.canvasElementId) === null) {
throw new Error('Cannot find existing element in the DOM, please ensure element is created prior to engine creation.');
}

this.canvas = <HTMLCanvasElement>document.getElementById(options.canvasElementId);
} else if (options.canvasElement) {
this._logger.debug('Using Canvas element specified:', options.canvasElement);
Expand Down

0 comments on commit 9c46824

Please sign in to comment.