Skip to content

Commit

Permalink
fix(i3s-scene-parser): provide unsupported layer types in the excepti…
Browse files Browse the repository at this point in the history
…on (#2863)
  • Loading branch information
mspivak-actionengine authored Jan 30, 2024
1 parent e5ff5fb commit 27f6384
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/i3s/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ export {ArcGISWebSceneLoader} from './arcgis-webscene-loader';

export type {SLPKArchive} from './lib/parsers/parse-slpk/slpk-archieve';
export {parseSLPKArchive} from './lib/parsers/parse-slpk/parse-slpk';
export {LayerError} from './lib/parsers/parse-arcgis-webscene';
export {customizeColors} from './lib/utils/customize-colors';
18 changes: 17 additions & 1 deletion modules/i3s/src/lib/parsers/parse-arcgis-webscene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ const SUPPORTED_LAYERS_TYPES = [
const NO_AVAILABLE_SUPPORTED_LAYERS_ERROR = 'NO_AVAILABLE_SUPPORTED_LAYERS_ERROR';
const NOT_SUPPORTED_CRS_ERROR = 'NOT_SUPPORTED_CRS_ERROR';

/**
* Provides additional information in the exception Error object, e.g. unsupported layer types.
* @param message - message used in the Error object
* @param details - additional information that can be used to handle the exception.
* @example throw new LayerError(NO_AVAILABLE_SUPPORTED_LAYERS_ERROR, unsupportedLayers);
*/
export class LayerError extends Error {
constructor(
message: string,
public details: unknown
) {
super(message);
this.name = 'LayerError';
}
}

/**
* Parses ArcGIS WebScene
* @param data
Expand All @@ -36,7 +52,7 @@ export async function parseWebscene(data: ArrayBuffer): Promise<ArcGISWebSceneDa
const {layers, unsupportedLayers} = await parseOperationalLayers(operationalLayers, true);

if (!layers.length) {
throw new Error(NO_AVAILABLE_SUPPORTED_LAYERS_ERROR);
throw new LayerError(NO_AVAILABLE_SUPPORTED_LAYERS_ERROR, unsupportedLayers);
}

return {
Expand Down

0 comments on commit 27f6384

Please sign in to comment.