forked from MapComplete/MapComplete
Better error handling
This commit is contained in:
parent
f227689208
commit
913c17a76e
2 changed files with 9 additions and 4 deletions
|
@ -24,6 +24,11 @@ class HandleErrors extends Script {
|
||||||
const refusedFiles: Set<string> = new Set<string>()
|
const refusedFiles: Set<string> = new Set<string>()
|
||||||
refusedFiles.add("[]")
|
refusedFiles.add("[]")
|
||||||
|
|
||||||
|
const changesObj = new Changes({
|
||||||
|
dryRun: new ImmutableStore(true),
|
||||||
|
osmConnection,
|
||||||
|
}, false, err => console.error(err))
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (!line?.trim()) {
|
if (!line?.trim()) {
|
||||||
continue
|
continue
|
||||||
|
@ -75,7 +80,7 @@ class HandleErrors extends Script {
|
||||||
.filter((obj) => obj.osmObj !== "deleted")
|
.filter((obj) => obj.osmObj !== "deleted")
|
||||||
.map((obj) => <OsmObject>obj.osmObj)
|
.map((obj) => <OsmObject>obj.osmObj)
|
||||||
|
|
||||||
const { toUpload, refused } = Changes.fragmentChanges(e.pendingChanges, objects)
|
const { toUpload, refused } = changesObj.fragmentChanges(e.pendingChanges, objects)
|
||||||
|
|
||||||
const changes: {
|
const changes: {
|
||||||
newObjects: OsmObject[]
|
newObjects: OsmObject[]
|
||||||
|
|
|
@ -557,7 +557,7 @@ export class Changes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static fragmentChanges(
|
public fragmentChanges(
|
||||||
pending: ChangeDescription[],
|
pending: ChangeDescription[],
|
||||||
objects: OsmObject[]
|
objects: OsmObject[]
|
||||||
): {
|
): {
|
||||||
|
@ -576,7 +576,7 @@ export class Changes {
|
||||||
if (createdIds.has(c.id)) {
|
if (createdIds.has(c.id)) {
|
||||||
toUpload.push(c)
|
toUpload.push(c)
|
||||||
} else {
|
} else {
|
||||||
reportError(
|
(this._reportError)(
|
||||||
`Got an orphaned change. The 'creation'-change description for ${c.type}/${c.id} got lost. Permanently dropping this change:` +
|
`Got an orphaned change. The 'creation'-change description for ${c.type}/${c.id} got lost. Permanently dropping this change:` +
|
||||||
JSON.stringify(c)
|
JSON.stringify(c)
|
||||||
)
|
)
|
||||||
|
@ -706,7 +706,7 @@ export class Changes {
|
||||||
...perBinMessage,
|
...perBinMessage,
|
||||||
]
|
]
|
||||||
|
|
||||||
let { toUpload, refused } = Changes.fragmentChanges(pending, objects)
|
let { toUpload, refused } = this.fragmentChanges(pending, objects)
|
||||||
|
|
||||||
await this._changesetHandler.UploadChangeset(
|
await this._changesetHandler.UploadChangeset(
|
||||||
(csId, remappings) => {
|
(csId, remappings) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue