Skip to content

Commit

Permalink
should not have caught the error
Browse files Browse the repository at this point in the history
  • Loading branch information
jptmoore committed Sep 16, 2024
1 parent d50b09d commit 59420f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maniiifest",
"version": "1.2.1",
"version": "1.2.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
Expand Down
34 changes: 15 additions & 19 deletions src/Maniiifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,21 @@ export class Maniiifest {
* @throws {Error} Throws an error if an unsupported type is provided.
*/
constructor(data: any, type?: string) {
try {
switch (type) {
case "AnnotationCollection":
this.specification = F.readAnnotationCollectionT(data);
break;
case "AnnotationPage":
this.specification = F.readAnnotationPageT(data);
break;
case "Annotation":
this.specification = F.readAnnotationT(data);
break;
case undefined:
this.specification = F.readSpecificationT(data);
break;
default:
throw new Error(`Unsupported type: ${type}`);
}
} catch (error) {
console.error("Failed to read specification:", error);
switch (type) {
case "AnnotationCollection":
this.specification = F.readAnnotationCollectionT(data);
break;
case "AnnotationPage":
this.specification = F.readAnnotationPageT(data);
break;
case "Annotation":
this.specification = F.readAnnotationT(data);
break;
case undefined:
this.specification = F.readSpecificationT(data);
break;
default:
throw new Error(`Unsupported type: ${type}`);
}
}

Expand Down

0 comments on commit 59420f5

Please sign in to comment.