Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected onError(error: Error) {
if (this.state === TileLoaderState.Canceled) {
// If we're canceled, we should simply ignore any state transitions and errors from
// underlying load/decode ops.
return;
}
const dataSource = this.dataSource;
logger.error(
`[${dataSource.name}]: failed to load tile ${this.tileKey.mortonCode()}`,
error
);
this.error = error;
this.onDone(TileLoaderState.Failed);
}
}
loadAndDecode(): Promise {
switch (this.state) {
case TileLoaderState.Loading:
case TileLoaderState.Loaded:
case TileLoaderState.Decoding:
// tile is already loading
this.countRequests++;
return this.donePromise!;
case TileLoaderState.Ready:
case TileLoaderState.Failed:
case TileLoaderState.Initialized:
case TileLoaderState.Canceled:
// restart loading
this.countRequests++;
this.startLoading();
return this.donePromise!;
}
}
}
switch (this.state) {
case TileLoaderState.Loading:
this.loadAbortController.abort();
this.loadAbortController = new AbortController();
break;
case TileLoaderState.Decoding:
if (this.requestController) {
this.requestController.abort();
this.requestController = undefined;
}
break;
}
this.onDone(TileLoaderState.Canceled);
}