vamos
This commit is contained in:
@@ -129,11 +129,28 @@ export const useMusicStore = defineStore('music', {
|
||||
try {
|
||||
const encodedName = encodeURIComponent(name)
|
||||
const response = await fetch(`/api/music/${encodedName}`)
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`)
|
||||
|
||||
if (!response.ok) {
|
||||
const errorMsg = `HTTP ${response.status}`
|
||||
|
||||
// Detect authentication errors
|
||||
if (response.status === 401 || response.status === 403) {
|
||||
console.warn('[Music Store] Cache failed - authentication error:', response.status)
|
||||
this.error = `${errorMsg}: Unauthorized - Please log in`
|
||||
}
|
||||
|
||||
throw new Error(errorMsg)
|
||||
}
|
||||
|
||||
const blob = await response.blob()
|
||||
await this.saveTrackBlob(name, blob, duration)
|
||||
return true
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('[Music Store] Cache failed:', e)
|
||||
// Propagate auth errors
|
||||
if (e?.message?.includes('401') || e?.message?.includes('403')) {
|
||||
this.error = e.message
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user