Skip to content

Commit e9a4648

Browse files
author
Dennis Labordus
committed
Added check on NOT_FOUND to show correct message.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent c04e0aa commit e9a4648

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/compas-editors/CompasVersions.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {get, translate} from 'lit-translate';
33
import {newLogEvent, newWizardEvent, Wizard} from "../foundation.js";
44

55
import {CompasSclDataService, SDS_NAMESPACE} from "../compas-services/CompasSclDataService.js";
6-
import {createLogEvent} from "../compas-services/foundation.js";
6+
import {createLogEvent, isNotFoundError, NOT_FOUND_ERROR} from "../compas-services/foundation.js";
77
import {getTypeFromDocName, updateDocumentInOpenSCD} from "../compas/foundation.js";
88
import {getElementByName, getOpenScdElement, styles} from './foundation.js';
99
import {addVersionToCompasWizard} from "../compas/CompasUploadVersion.js";
@@ -53,6 +53,11 @@ export default class CompasVersionsPlugin extends LitElement {
5353
CompasSclDataService().listVersions(type, this.docId)
5454
.then(xmlResponse => {
5555
this.scls = Array.from(xmlResponse.querySelectorAll('Item') ?? []);
56+
})
57+
.catch(reason => {
58+
if (isNotFoundError(reason)) {
59+
this.scls = [];
60+
}
5661
});
5762
}
5863

src/compas-services/foundation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ export function handleError(error: Error): Promise<never> {
6969
return Promise.reject({type: SERVER_ERROR, message: error.message});
7070
}
7171

72+
export function isNotFoundError(reason: any): boolean {
73+
return (reason.type && reason.type === NOT_FOUND_ERROR);
74+
}
75+
7276
export function createLogEvent(reason: any): void {
7377
let message = reason.message;
7478
if (reason.status) {

src/compas/CompasExistsIn.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {property} from "lit-element";
33
import {LitElementConstructor, Mixin} from "../foundation.js";
44

55
import {CompasSclDataService} from "../compas-services/CompasSclDataService.js";
6-
import {NOT_FOUND_ERROR} from "../compas-services/foundation.js";
6+
import {isNotFoundError, NOT_FOUND_ERROR} from "../compas-services/foundation.js";
77
import {getTypeFromDocName} from "./foundation.js";
88

99
export type CompasExistsInElement = Mixin<typeof CompasExistsIn>;
@@ -33,7 +33,7 @@ export function CompasExistsIn<TBase extends LitElementConstructor>(Base: TBase)
3333
this.callService(docType, this.docId)
3434
.then(() => this.existInCompas = true)
3535
.catch(reason => {
36-
if (reason.type && reason.type === NOT_FOUND_ERROR) {
36+
if (isNotFoundError(reason)) {
3737
this.existInCompas = false;
3838
}
3939
});

0 commit comments

Comments
 (0)