fix: log sharing in app + clearing (#5801)

* fix: log wiping app

* fix: share modal rounded
This commit is contained in:
Calum H.
2026-04-13 16:52:35 +02:00
committed by GitHub
parent b666747bc2
commit d5ad1cb823
5 changed files with 66 additions and 7 deletions

View File

@@ -23,8 +23,50 @@ export class VerboseLoggingFeature extends AbstractFeature {
}
return result
} catch (error) {
console.debug(`${prefix} ${context.url} FAILED`)
const details = formatErrorDetails(error)
console.debug(`${prefix} ${context.url} FAILED${details ? `${details}` : ''}`)
throw error
}
}
}
function formatErrorDetails(error: unknown): string {
if (!error || typeof error !== 'object') {
return typeof error === 'string' ? error : ''
}
const err = error as {
status?: number
statusCode?: number
statusText?: string
message?: string
data?: unknown
responseData?: unknown
originalError?: unknown
response?: { status?: number; statusText?: string; _data?: unknown }
}
const status = err.status ?? err.statusCode ?? err.response?.status
const statusText = err.statusText ?? err.response?.statusText
const data = err.responseData ?? err.data ?? err.response?._data
const parts: string[] = []
if (status !== undefined) {
parts.push(statusText ? `${status} ${statusText}` : String(status))
}
if (data !== undefined) {
parts.push(`body: ${safeStringify(data)}`)
} else if (err.message) {
parts.push(err.message)
}
return parts.join(' ')
}
function safeStringify(value: unknown): string {
if (typeof value === 'string') return value
try {
return JSON.stringify(value)
} catch {
return String(value)
}
}

View File

@@ -60,10 +60,18 @@ export class TauriModrinthClient extends XHRUploadClient {
let body: BodyInit | null | undefined = undefined
if (options.body) {
if (typeof options.body === 'object' && !(options.body instanceof FormData)) {
body = JSON.stringify(options.body)
const raw = options.body
if (
typeof raw === 'object' &&
!(raw instanceof FormData) &&
!(raw instanceof URLSearchParams) &&
!(raw instanceof Blob) &&
!(raw instanceof ArrayBuffer) &&
!ArrayBuffer.isView(raw as ArrayBufferView)
) {
body = JSON.stringify(raw)
} else {
body = options.body as BodyInit
body = raw as BodyInit
}
}