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

ensure building creation handles errors graciously #743

Open
derrabauke opened this issue Apr 9, 2024 · 2 comments
Open

ensure building creation handles errors graciously #743

derrabauke opened this issue Apr 9, 2024 · 2 comments

Comments

@derrabauke
Copy link
Contributor

As an additional fix, we should ensure that building creation handles errors graciously, i.e. if when saving a building, if the addWork request fails or the addBuildingToConstructionProject, then the building should be left in a new state. At the moment we trigger modifyBuilding requests after a failed addBuildingToConstructionProject because the isNew flag isn't rolled back correctly.

Originally posted by @luytena in #741 (comment)

@derrabauke
Copy link
Contributor Author

@luytena I guess you are referring to this?

if (this.buildingWork.isNew) {
const building = yield this.buildingAPI.create(
this.model.projectId,
this.buildingWork,
);
EGID = building.EGID;
} else {
yield this.buildingAPI.update(this.buildingWork.building);

@luytena
Copy link
Contributor

luytena commented Apr 9, 2024

@luytena I guess you are referring to this?

if (this.buildingWork.isNew) {
const building = yield this.buildingAPI.create(
this.model.projectId,
this.buildingWork,
);
EGID = building.EGID;
} else {
yield this.buildingAPI.update(this.buildingWork.building);

Yes, in the create method in essence any exception that causes it to not go by the line buildingWork.isNew = true;

await this.constructionProject.removeWorkFromProject(EPROID, work.ARBID);
buildingWork.ARBID = undefined;
buildingWork.isNew = true;
console.error("GWR API: addBuildingToConstructionProject failed");
throw errors;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants