Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/download-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class DownloadRequest extends TypedEventTarget<
this.#updateState({ status: 'canceled' })
} else if (getErrorCode(error)) {
// Specific known error from the server
this.#updateState({ status: 'error', error })
this.#updateState({ status: 'error', error: jsonError(error) })
} else {
// Once the download has started, the sender can only close the
// connection to cancel the download, which we only see as an
Expand Down
4 changes: 2 additions & 2 deletions src/lib/map-share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type DownloadStateUpdate,
type MapInfo,
} from '../types.js'
import { errors } from './errors.js'
import { errors, jsonError } from './errors.js'
import { StateUpdateEvent } from './state-update-event.js'
import { addTrailingSlash, generateId, getErrorCode } from './utils.js'

Expand Down Expand Up @@ -155,7 +155,7 @@ export class DownloadResponse extends TypedEventTarget<
} else if (getErrorCode(error) === 'ECONNRESET') {
this.#updateState({ status: 'aborted' })
} else {
this.#updateState({ status: 'error', error })
this.#updateState({ status: 'error', error: jsonError(error) })
}
})

Expand Down
4 changes: 4 additions & 0 deletions test/map-shares.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ describe('Map Shares and Downloads', () => {
'error.code',
'DOWNLOAD_SHARE_NOT_PENDING',
)
expect(events.at(-1)).toHaveProperty('error.message')

await completedPromise
}, 2000)
Expand All @@ -385,6 +386,7 @@ describe('Map Shares and Downloads', () => {
'error.code',
'DOWNLOAD_SHARE_NOT_PENDING',
)
expect(events.at(-1)).toHaveProperty('error.message')
})
})

Expand Down Expand Up @@ -582,6 +584,7 @@ describe('Map Shares and Downloads', () => {
'error.code',
'DOWNLOAD_SHARE_DECLINED',
)
expect(events.at(-1)).toHaveProperty('error.message')
})

it('should reject decline on non-pending share', async (t) => {
Expand Down Expand Up @@ -1590,6 +1593,7 @@ describe('Map Shares and Downloads', () => {
.json<any>()
expect(downloadStatus.status).toBe('error')
expect(downloadStatus).toHaveProperty('error.code', 'DOWNLOAD_ERROR')
expect(downloadStatus).toHaveProperty('error.message')
})

it('should clean up temp files on download error', async (t) => {
Expand Down