Improve error reporting, first attempt for script which handles the errors
This commit is contained in:
parent
b4ffdbd942
commit
4ef3429c5a
6 changed files with 117 additions and 11 deletions
|
@ -13,10 +13,6 @@ import { ChangesetHandler, ChangesetTag } from "./ChangesetHandler"
|
|||
import { OsmConnection } from "./OsmConnection"
|
||||
import FeaturePropertiesStore from "../FeatureSource/Actors/FeaturePropertiesStore"
|
||||
import OsmObjectDownloader from "./OsmObjectDownloader"
|
||||
import Combine from "../../UI/Base/Combine"
|
||||
import BaseUIElement from "../../UI/BaseUIElement"
|
||||
import Title from "../../UI/Base/Title"
|
||||
import Table from "../../UI/Base/Table"
|
||||
import ChangeLocationAction from "./Actions/ChangeLocationAction"
|
||||
import ChangeTagAction from "./Actions/ChangeTagAction"
|
||||
import FeatureSwitchState from "../State/FeatureSwitchState"
|
||||
|
@ -44,7 +40,7 @@ export class Changes {
|
|||
private _nextId: number = -1 // Newly assigned ID's are negative
|
||||
private readonly previouslyCreated: OsmObject[] = []
|
||||
private readonly _leftRightSensitive: boolean
|
||||
private readonly _changesetHandler: ChangesetHandler
|
||||
public readonly _changesetHandler: ChangesetHandler
|
||||
private readonly _reportError?: (string: string | Error) => void
|
||||
|
||||
constructor(
|
||||
|
@ -209,7 +205,7 @@ export class Changes {
|
|||
].join("\n\n")
|
||||
}
|
||||
|
||||
private static GetNeededIds(changes: ChangeDescription[]) {
|
||||
public static GetNeededIds(changes: ChangeDescription[]) {
|
||||
return Utils.Dedup(changes.filter((c) => c.id >= 0).map((c) => c.type + "/" + c.id))
|
||||
}
|
||||
|
||||
|
@ -520,7 +516,7 @@ export class Changes {
|
|||
const osmObj = await downloader.DownloadObjectAsync(id, 0)
|
||||
return { id, osmObj }
|
||||
} catch (e) {
|
||||
const msg = "Could not download OSM-object" +
|
||||
const msg = "Could not download OSM-object " +
|
||||
id +
|
||||
" trying again before dropping it from the changes (" +
|
||||
e +
|
||||
|
@ -530,7 +526,7 @@ export class Changes {
|
|||
return { id, osmObj }
|
||||
}
|
||||
} catch (e) {
|
||||
const msg = "Could not download OSM-object" +
|
||||
const msg = "Could not download OSM-object " +
|
||||
id +
|
||||
" dropping it from the changes (" +
|
||||
e +
|
||||
|
|
|
@ -25,7 +25,7 @@ export class ChangesetHandler {
|
|||
* Contains previously rewritten IDs
|
||||
* @private
|
||||
*/
|
||||
private readonly _remappings = new Map<string, string>()
|
||||
public readonly _remappings = new Map<string, string>()
|
||||
private readonly _reportError: (e: string | Error) => void
|
||||
|
||||
constructor(
|
||||
|
@ -187,7 +187,7 @@ export class ChangesetHandler {
|
|||
await this.UpdateTags(csId, rewrittenTags)
|
||||
} catch (e) {
|
||||
if (this._reportError) {
|
||||
this._reportError("Could not reuse changeset, might be closed: " + e.stacktrace ?? "" + e)
|
||||
this._reportError("Could not reuse changeset "+csId+", might be closed: " + (e.stacktrace ?? ("" + e)))
|
||||
}
|
||||
console.warn("Could not upload, changeset is probably closed: ", e)
|
||||
openChangeset.setData(undefined)
|
||||
|
|
|
@ -900,6 +900,8 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
|||
username: this.osmConnection.userDetails.data?.name,
|
||||
userid: this.osmConnection.userDetails.data?.uid,
|
||||
pendingChanges: this.changes.pendingChanges.data,
|
||||
previousChanges: this.changes.allChanges.data,
|
||||
changeRewrites: Utils.MapToObj(this.changes._changesetHandler._remappings)
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1267,13 +1267,21 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
|
|||
return track[str2.length][str1.length]
|
||||
}
|
||||
|
||||
public static MapToObj<V>(
|
||||
d: Map<string, V>
|
||||
): Record<string, V>;
|
||||
public static MapToObj<V, T>(
|
||||
d: Map<string, V>,
|
||||
onValue: (t: V, key: string) => T
|
||||
): Record<string, T>
|
||||
public static MapToObj<V, T>(
|
||||
d: Map<string, V>,
|
||||
onValue: (t: V, key: string) => T = undefined
|
||||
): Record<string, T> {
|
||||
const o = {}
|
||||
const keys = Array.from(d.keys())
|
||||
keys.sort()
|
||||
onValue ??= (v => <any> v)
|
||||
for (const key of keys) {
|
||||
o[key] = onValue(d.get(key), key)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue