Better error handling

This commit is contained in:
Pieter Vander Vennet 2024-07-31 11:10:35 +02:00
parent f227689208
commit 913c17a76e
2 changed files with 9 additions and 4 deletions

View file

@ -24,6 +24,11 @@ class HandleErrors extends Script {
const refusedFiles: Set<string> = new Set<string>()
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) => <OsmObject>obj.osmObj)
const { toUpload, refused } = Changes.fragmentChanges(e.pendingChanges, objects)
const { toUpload, refused } = changesObj.fragmentChanges(e.pendingChanges, objects)
const changes: {
newObjects: OsmObject[]

View file

@ -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) => {