From 913c17a76eb9969db4b638d942c455632bcb67c0 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 31 Jul 2024 11:10:35 +0200 Subject: [PATCH] Better error handling --- scripts/handleErrors.ts | 7 ++++++- src/Logic/Osm/Changes.ts | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/handleErrors.ts b/scripts/handleErrors.ts index 7e8bd56c1..c946809e7 100644 --- a/scripts/handleErrors.ts +++ b/scripts/handleErrors.ts @@ -24,6 +24,11 @@ class HandleErrors extends Script { const refusedFiles: Set = new Set() refusedFiles.add("[]") + const changesObj = new Changes({ + dryRun: new ImmutableStore(true), + osmConnection, + }, false, err => console.error(err)) + for (const line of lines) { if (!line?.trim()) { continue @@ -75,7 +80,7 @@ class HandleErrors extends Script { .filter((obj) => obj.osmObj !== "deleted") .map((obj) => obj.osmObj) - const { toUpload, refused } = Changes.fragmentChanges(e.pendingChanges, objects) + const { toUpload, refused } = changesObj.fragmentChanges(e.pendingChanges, objects) const changes: { newObjects: OsmObject[] diff --git a/src/Logic/Osm/Changes.ts b/src/Logic/Osm/Changes.ts index 18d359d11..ea809e04e 100644 --- a/src/Logic/Osm/Changes.ts +++ b/src/Logic/Osm/Changes.ts @@ -557,7 +557,7 @@ export class Changes { } } - public static fragmentChanges( + public fragmentChanges( pending: ChangeDescription[], objects: OsmObject[] ): { @@ -576,7 +576,7 @@ export class Changes { if (createdIds.has(c.id)) { toUpload.push(c) } else { - reportError( + (this._reportError)( `Got an orphaned change. The 'creation'-change description for ${c.type}/${c.id} got lost. Permanently dropping this change:` + JSON.stringify(c) ) @@ -706,7 +706,7 @@ export class Changes { ...perBinMessage, ] - let { toUpload, refused } = Changes.fragmentChanges(pending, objects) + let { toUpload, refused } = this.fragmentChanges(pending, objects) await this._changesetHandler.UploadChangeset( (csId, remappings) => {