Add network fetch error messages
This commit is contained in:
@@ -25,6 +25,9 @@ export const languageEnglish = {
|
|||||||
noUserIcon: "You must set your icon first.",
|
noUserIcon: "You must set your icon first.",
|
||||||
emptyText: "Text is empty.",
|
emptyText: "Text is empty.",
|
||||||
wrongPassword: "Wrong Password",
|
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",
|
showHelp: "Show Help",
|
||||||
help:{
|
help:{
|
||||||
|
|||||||
@@ -68,6 +68,9 @@
|
|||||||
}}>Terms of Service</a> to continue</div>
|
}}>Terms of Service</a> to continue</div>
|
||||||
{:else if $alertStore.type !== 'select'}
|
{:else if $alertStore.type !== 'select'}
|
||||||
<span class="text-gray-300">{$alertStore.msg}</span>
|
<span class="text-gray-300">{$alertStore.msg}</span>
|
||||||
|
{#if $alertStore.submsg}
|
||||||
|
<span class="text-gray-500 text-sm">{$alertStore.submsg}</span>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#if $alertStore.type === 'ask'}
|
{#if $alertStore.type === 'ask'}
|
||||||
<div class="flex gap-2 w-full">
|
<div class="flex gap-2 w-full">
|
||||||
|
|||||||
@@ -1,24 +1,38 @@
|
|||||||
import { get, writable } from "svelte/store"
|
import { get, writable } from "svelte/store"
|
||||||
import { sleep } from "./util"
|
import { sleep } from "./util"
|
||||||
import { language } from "../lang"
|
import { language } from "../lang"
|
||||||
|
import { isNodeServer, isTauri } from "./storage/globalApi"
|
||||||
|
import { Capacitor } from "@capacitor/core"
|
||||||
|
import { DataBase } from "./storage/database"
|
||||||
|
|
||||||
interface alertData{
|
interface alertData{
|
||||||
type: 'error'| 'normal'|'none'|'ask'|'wait'|'selectChar'|'input'|'toast'|'wait2'|'markdown'|'select'|'login'|'tos'|'cardexport'
|
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({
|
export const alertStore = writable({
|
||||||
type: 'none',
|
type: 'none',
|
||||||
msg: 'n'
|
msg: 'n',
|
||||||
} as alertData)
|
} as alertData)
|
||||||
|
|
||||||
export function alertError(msg:string){
|
export function alertError(msg:string){
|
||||||
console.error(msg)
|
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({
|
alertStore.set({
|
||||||
'type': 'error',
|
'type': 'error',
|
||||||
'msg': msg
|
'msg': msg,
|
||||||
|
'submsg': submsg
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user