mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 03:55:59 +00:00
37 lines
924 B
JavaScript
37 lines
924 B
JavaScript
import { defineStore } from 'pinia'
|
|
|
|
import { findMinecraftAuthError } from '@/components/ui/minecraft-auth-error-modal/minecraft-auth-errors'
|
|
|
|
export const useError = defineStore('errorsStore', {
|
|
state: () => ({
|
|
errorModal: null,
|
|
minecraftAuthErrorModal: null,
|
|
}),
|
|
actions: {
|
|
setErrorModal(ref) {
|
|
this.errorModal = ref
|
|
},
|
|
setMinecraftAuthErrorModal(ref) {
|
|
this.minecraftAuthErrorModal = ref
|
|
},
|
|
showError(error, context, closable = true, source = null) {
|
|
if (
|
|
error.message &&
|
|
(error.message.includes('Minecraft authentication error:') ||
|
|
findMinecraftAuthError(error.message)) &&
|
|
this.minecraftAuthErrorModal
|
|
) {
|
|
this.minecraftAuthErrorModal.show(error)
|
|
return
|
|
}
|
|
this.errorModal.show(error, context, closable, source)
|
|
},
|
|
},
|
|
})
|
|
|
|
export const handleSevereError = (err, context) => {
|
|
const error = useError()
|
|
error.showError(err, context)
|
|
console.error(err)
|
|
}
|