Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(i3s-scene-parser): provide unsupported layer types in the exception #2863

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading