Add network fetch error messages

This commit is contained in:
kwaroran
2024-03-16 14:57:37 +09:00
parent 3224d435d3
commit 18f342437e
3 changed files with 23 additions and 3 deletions

View File

@@ -25,6 +25,9 @@ export const languageEnglish = {
noUserIcon: "You must set your icon first.",
emptyText: "Text is empty.",
wrongPassword: "Wrong Password",
networkFetch: "This happens when the network is unstable or the server is down.",
networkFetchWeb: "This can be a CORS error. this only happens when using web version dude to limitations of the browser. try using desktop local version, or other version of RisuAI.",
networkFetchPlain: "This can be a plain fetch error. try disabling force plain fetch option in settings.",
},
showHelp: "Show Help",
help:{

View File

@@ -68,6 +68,9 @@
}}>Terms of Service</a> to continue</div>
{:else if $alertStore.type !== 'select'}
<span class="text-gray-300">{$alertStore.msg}</span>
{#if $alertStore.submsg}
<span class="text-gray-500 text-sm">{$alertStore.submsg}</span>
{/if}
{/if}
{#if $alertStore.type === 'ask'}
<div class="flex gap-2 w-full">

View File

@@ -1,24 +1,38 @@
import { get, writable } from "svelte/store"
import { sleep } from "./util"
import { language } from "../lang"
import { isNodeServer, isTauri } from "./storage/globalApi"
import { Capacitor } from "@capacitor/core"
import { DataBase } from "./storage/database"
interface alertData{
type: 'error'| 'normal'|'none'|'ask'|'wait'|'selectChar'|'input'|'toast'|'wait2'|'markdown'|'select'|'login'|'tos'|'cardexport'
msg: string
msg: string,
submsg?: string
}
export const alertStore = writable({
type: 'none',
msg: 'n'
msg: 'n',
} as alertData)
export function alertError(msg:string){
console.error(msg)
const db = get(DataBase)
let submsg = ''
//check if it's a known error
if(msg.includes('Failed to fetch') || msg.includes("NetworkError when attempting to fetch resource.")){
submsg = db.usePlainFetch ? language.errors.networkFetchPlain :
(!isTauri && !isNodeServer && !Capacitor.isNativePlatform()) ? language.errors.networkFetchWeb : language.errors.networkFetch
}
alertStore.set({
'type': 'error',
'msg': msg
'msg': msg,
'submsg': submsg
})
}