Fix: add error reporting when image upload fails, see #2202

This commit is contained in:
Pieter Vander Vennet 2024-10-10 23:09:31 +02:00
parent cc6ce3c271
commit 368d7857a0
2 changed files with 6 additions and 1 deletions

View file

@ -28,6 +28,7 @@ export class ImageUploadManager {
private readonly _osmConnection: OsmConnection private readonly _osmConnection: OsmConnection
private readonly _changes: Changes private readonly _changes: Changes
public readonly isUploading: Store<boolean> public readonly isUploading: Store<boolean>
private readonly _reportError: (message: (string | Error | XMLHttpRequest), extramessage?: string) => Promise<void>
constructor( constructor(
layout: LayoutConfig, layout: LayoutConfig,
@ -37,6 +38,7 @@ export class ImageUploadManager {
changes: Changes, changes: Changes,
gpsLocation: Store<GeolocationCoordinates | undefined>, gpsLocation: Store<GeolocationCoordinates | undefined>,
allFeatures: IndexedFeatureSource, allFeatures: IndexedFeatureSource,
reportError: (message: string | Error | XMLHttpRequest, extramessage?: string ) => Promise<void>
) { ) {
this._uploader = uploader this._uploader = uploader
this._featureProperties = featureProperties this._featureProperties = featureProperties
@ -45,6 +47,7 @@ export class ImageUploadManager {
this._changes = changes this._changes = changes
this._indexedFeatures = allFeatures this._indexedFeatures = allFeatures
this._gps = gpsLocation this._gps = gpsLocation
this._reportError = reportError
const failed = this.getCounterFor(this._uploadFailed, "*") const failed = this.getCounterFor(this._uploadFailed, "*")
const done = this.getCounterFor(this._uploadFinished, "*") const done = this.getCounterFor(this._uploadFinished, "*")
@ -163,6 +166,7 @@ export class ImageUploadManager {
} catch (e) { } catch (e) {
console.error("Could again not upload image due to", e) console.error("Could again not upload image due to", e)
this.increaseCountFor(this._uploadFailed, featureId) this.increaseCountFor(this._uploadFailed, featureId)
await this._reportError(e, JSON.stringify({ctx:"While uploading an image in the Image Upload Manager", featureId, author, targetKey}))
return undefined return undefined
} }
} }

View file

@ -369,7 +369,8 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.osmConnection, this.osmConnection,
this.changes, this.changes,
this.geolocation.geolocationState.currentGPSLocation, this.geolocation.geolocationState.currentGPSLocation,
this.indexedFeatures this.indexedFeatures,
this.reportError
) )
this.favourites = new FavouritesFeatureSource(this) this.favourites = new FavouritesFeatureSource(this)
const longAgo = new Date() const longAgo = new Date()