You've already forked AstralRinth
forked from didirus/AstralRinth
Error handling (#121)
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
<div v-else class="logged-out account">
|
||||
<h4>Not signed in</h4>
|
||||
<Button icon-only color="primary" @click="login()">
|
||||
<LoginIcon />
|
||||
<LogInIcon />
|
||||
</Button>
|
||||
</div>
|
||||
<div v-if="displayAccounts.length > 0" class="account-group">
|
||||
@@ -54,8 +54,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Avatar, Button, Card, PlusIcon, XIcon } from 'omorphia'
|
||||
import { LoginIcon, UsersIcon } from '@/assets/icons'
|
||||
import { Avatar, Button, Card, PlusIcon, XIcon, UsersIcon, LogInIcon } from 'omorphia'
|
||||
import { ref, defineProps, computed, onMounted, onBeforeUnmount } from 'vue'
|
||||
import {
|
||||
users,
|
||||
@@ -65,6 +64,7 @@ import {
|
||||
} from '@/helpers/auth'
|
||||
import { get, set } from '@/helpers/settings'
|
||||
import { WebviewWindow } from '@tauri-apps/api/window'
|
||||
import { handleError } from '@/store/state.js'
|
||||
|
||||
defineProps({
|
||||
expanded: {
|
||||
@@ -73,7 +73,7 @@ defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const settings = ref(await get())
|
||||
const settings = ref(await get().catch(handleError))
|
||||
|
||||
const appendProfiles = (accounts) => {
|
||||
return accounts.map((account) => {
|
||||
@@ -84,7 +84,7 @@ const appendProfiles = (accounts) => {
|
||||
})
|
||||
}
|
||||
|
||||
const accounts = ref(await users().then(appendProfiles))
|
||||
const accounts = ref(await users().then(appendProfiles).catch(handleError))
|
||||
|
||||
const displayAccounts = computed(() =>
|
||||
accounts.value.filter((account) => settings.value.default_user !== account.id)
|
||||
@@ -95,7 +95,7 @@ const selectedAccount = ref(
|
||||
)
|
||||
|
||||
const refreshValues = async () => {
|
||||
accounts.value = await users().then(appendProfiles)
|
||||
accounts.value = await users().then(appendProfiles).catch(handleError)
|
||||
selectedAccount.value = accounts.value.find(
|
||||
(account) => account.id === settings.value.default_user
|
||||
)
|
||||
@@ -108,11 +108,11 @@ let button = ref(null)
|
||||
const setAccount = async (account) => {
|
||||
settings.value.default_user = account.id
|
||||
selectedAccount.value = account
|
||||
await set(settings.value)
|
||||
await set(settings.value).catch(handleError)
|
||||
}
|
||||
|
||||
const login = async () => {
|
||||
const url = await authenticate_begin_flow()
|
||||
const url = await authenticate_begin_flow().catch(handleError)
|
||||
|
||||
const window = new WebviewWindow('loginWindow', {
|
||||
url: url,
|
||||
@@ -126,14 +126,14 @@ const login = async () => {
|
||||
console.log('webview error', e)
|
||||
})
|
||||
|
||||
const loggedIn = await authenticate_await_completion()
|
||||
const loggedIn = await authenticate_await_completion().catch(handleError)
|
||||
await setAccount(loggedIn)
|
||||
await refreshValues()
|
||||
await window.close()
|
||||
}
|
||||
|
||||
const logout = async (id) => {
|
||||
await remove_user(id)
|
||||
await remove_user(id).catch(handleError)
|
||||
await refreshValues()
|
||||
if (!selectedAccount.value && accounts.value.length > 0) {
|
||||
await setAccount(accounts.value[0])
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
import { Button, Modal, XIcon, DownloadIcon, DropdownSelect, formatCategory } from 'omorphia'
|
||||
import { add_project_from_version as installMod } from '@/helpers/profile'
|
||||
import { defineExpose, ref } from 'vue'
|
||||
import { handleError } from '@/store/state.js'
|
||||
|
||||
const instance = ref(null)
|
||||
const projectTitle = ref(null)
|
||||
@@ -77,7 +78,7 @@ defineExpose({
|
||||
|
||||
const install = async () => {
|
||||
installing.value = true
|
||||
await installMod(instance.value.path, selectedVersion.value.id)
|
||||
await installMod(instance.value.path, selectedVersion.value.id).catch(handleError)
|
||||
installing.value = false
|
||||
markInstalled()
|
||||
incompatibleModal.value.hide()
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<script setup>
|
||||
import { onUnmounted, ref, useSlots } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ofetch } from 'ofetch'
|
||||
import { Card, SaveIcon, XIcon, Avatar, AnimatedLogo } from 'omorphia'
|
||||
import { PlayIcon } from '@/assets/icons'
|
||||
import { Card, SaveIcon, XIcon, Avatar, AnimatedLogo, PlayIcon } from 'omorphia'
|
||||
import { convertFileSrc } from '@tauri-apps/api/tauri'
|
||||
import InstallConfirmModal from '@/components/ui/InstallConfirmModal.vue'
|
||||
import { install as pack_install } from '@/helpers/pack'
|
||||
@@ -14,6 +12,8 @@ import {
|
||||
get_uuids_by_profile_path,
|
||||
} from '@/helpers/process'
|
||||
import { process_listener } from '@/helpers/events'
|
||||
import { useFetch } from '@/helpers/fetch.js'
|
||||
import { handleError } from '@/store/state.js'
|
||||
|
||||
const props = defineProps({
|
||||
instance: {
|
||||
@@ -46,7 +46,7 @@ const seeInstance = async () => {
|
||||
}
|
||||
|
||||
const checkProcess = async () => {
|
||||
const runningPaths = await get_all_running_profile_paths()
|
||||
const runningPaths = await get_all_running_profile_paths().catch(handleError)
|
||||
|
||||
if (runningPaths.includes(props.instance.path)) {
|
||||
playing.value = true
|
||||
@@ -60,12 +60,13 @@ const checkProcess = async () => {
|
||||
const install = async (e) => {
|
||||
e.stopPropagation()
|
||||
modLoading.value = true
|
||||
const versions = await ofetch(
|
||||
`https://api.modrinth.com/v2/project/${props.instance.project_id}/version`
|
||||
const versions = await useFetch(
|
||||
`https://api.modrinth.com/v2/project/${props.instance.project_id}/version`,
|
||||
'project versions'
|
||||
)
|
||||
|
||||
if (props.instance.project_type === 'modpack') {
|
||||
const packs = Object.values(await list(true))
|
||||
const packs = Object.values(await list(true).catch(handleError))
|
||||
|
||||
if (
|
||||
packs.length === 0 ||
|
||||
@@ -75,7 +76,9 @@ const install = async (e) => {
|
||||
) {
|
||||
try {
|
||||
modLoading.value = true
|
||||
await pack_install(versions[0].id, props.instance.title, props.instance.icon_url)
|
||||
await pack_install(versions[0].id, props.instance.title, props.instance.icon_url).catch(
|
||||
handleError
|
||||
)
|
||||
modLoading.value = false
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
@@ -91,7 +94,7 @@ const install = async (e) => {
|
||||
const play = async (e) => {
|
||||
e.stopPropagation()
|
||||
modLoading.value = true
|
||||
uuid.value = await run(props.instance.path)
|
||||
uuid.value = await run(props.instance.path).catch(handleError)
|
||||
modLoading.value = false
|
||||
playing.value = true
|
||||
}
|
||||
@@ -105,10 +108,10 @@ const stop = async (e) => {
|
||||
// from-then-back to this page, we will get all uuids by the instance path.
|
||||
// For-each uuid, kill the process.
|
||||
if (!uuid.value) {
|
||||
const uuids = await get_uuids_by_profile_path(props.instance.path)
|
||||
const uuids = await get_uuids_by_profile_path(props.instance.path).catch(handleError)
|
||||
uuid.value = uuids[0]
|
||||
uuids.forEach(async (u) => await kill_by_uuid(u))
|
||||
} else await kill_by_uuid(uuid.value) // If we still have the uuid, just kill it
|
||||
uuids.forEach(async (u) => await kill_by_uuid(u).catch(handleError))
|
||||
} else await kill_by_uuid(uuid.value).catch(handleError) // If we still have the uuid, just kill it
|
||||
} catch (err) {
|
||||
// Theseus currently throws:
|
||||
// "Error launching Minecraft: Minecraft exited with non-zero code 1" error
|
||||
|
||||
@@ -86,11 +86,9 @@ import { computed, ref, shallowRef } from 'vue'
|
||||
import { get_game_versions, get_loaders } from '@/helpers/tags'
|
||||
import { create } from '@/helpers/profile'
|
||||
import { open } from '@tauri-apps/api/dialog'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { tauri } from '@tauri-apps/api'
|
||||
import { get_fabric_versions, get_forge_versions, get_quilt_versions } from '@/helpers/metadata'
|
||||
|
||||
const router = useRouter()
|
||||
import { handleError } from '@/store/notifications.js'
|
||||
|
||||
const profile_name = ref('')
|
||||
const game_version = ref('')
|
||||
@@ -127,17 +125,18 @@ defineExpose({
|
||||
|
||||
const [fabric_versions, forge_versions, quilt_versions, all_game_versions, loaders] =
|
||||
await Promise.all([
|
||||
get_fabric_versions().then(shallowRef),
|
||||
get_forge_versions().then(shallowRef),
|
||||
get_quilt_versions().then(shallowRef),
|
||||
get_game_versions().then(shallowRef),
|
||||
get_fabric_versions().then(shallowRef).catch(handleError),
|
||||
get_forge_versions().then(shallowRef).catch(handleError),
|
||||
get_quilt_versions().then(shallowRef).catch(handleError),
|
||||
get_game_versions().then(shallowRef).catch(handleError),
|
||||
get_loaders()
|
||||
.then((value) =>
|
||||
value
|
||||
.filter((item) => item.supported_project_types.includes('modpack'))
|
||||
.map((item) => item.name.toLowerCase())
|
||||
)
|
||||
.then(ref),
|
||||
.then(ref)
|
||||
.catch(handleError),
|
||||
])
|
||||
loaders.value.push('vanilla')
|
||||
|
||||
@@ -172,15 +171,14 @@ const create_instance = async () => {
|
||||
const loader_version_value =
|
||||
loader_version.value === 'other' ? specified_loader_version.value : loader_version.value
|
||||
|
||||
const id = await create(
|
||||
await create(
|
||||
profile_name.value,
|
||||
game_version.value,
|
||||
loader.value,
|
||||
loader.value === 'vanilla' ? null : loader_version_value ?? 'stable',
|
||||
icon.value
|
||||
)
|
||||
).catch(handleError)
|
||||
|
||||
await router.push({ path: `/instance/${encodeURIComponent(id)}` })
|
||||
modal.value.hide()
|
||||
creating.value = false
|
||||
} catch (e) {
|
||||
|
||||
@@ -16,11 +16,10 @@ import { add_project_from_version as installMod, check_installed, list } from '@
|
||||
import { tauri } from '@tauri-apps/api'
|
||||
import { open } from '@tauri-apps/api/dialog'
|
||||
import { convertFileSrc } from '@tauri-apps/api/tauri'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { create } from '@/helpers/profile'
|
||||
import { installVersionDependencies } from '@/helpers/utils'
|
||||
import { handleError } from '@/store/notifications.js'
|
||||
|
||||
const router = useRouter()
|
||||
const versions = ref([])
|
||||
const project = ref('')
|
||||
const installModal = ref(null)
|
||||
@@ -55,7 +54,7 @@ async function install(instance) {
|
||||
)
|
||||
})
|
||||
|
||||
await installMod(instance.path, version.id)
|
||||
await installMod(instance.path, version.id).catch(handleError)
|
||||
await installVersionDependencies(instance, version)
|
||||
|
||||
instance.installedMod = true
|
||||
@@ -63,7 +62,7 @@ async function install(instance) {
|
||||
}
|
||||
|
||||
async function getData() {
|
||||
const projects = await list(true).then(Object.values)
|
||||
const projects = await list(true).then(Object.values).catch(handleError)
|
||||
|
||||
const filtered = projects
|
||||
.filter((profile) => {
|
||||
@@ -83,7 +82,7 @@ async function getData() {
|
||||
|
||||
for (let profile of filtered) {
|
||||
profile.installing = false
|
||||
profile.installedMod = await check_installed(profile.path, project.value)
|
||||
profile.installedMod = await check_installed(profile.path, project.value).catch(handleError)
|
||||
}
|
||||
|
||||
return filtered
|
||||
@@ -130,11 +129,10 @@ const createInstance = async () => {
|
||||
: 'vanilla',
|
||||
'latest',
|
||||
icon.value
|
||||
)
|
||||
).catch(handleError)
|
||||
|
||||
await installMod(id, versions.value[0].id)
|
||||
await installMod(id, versions.value[0].id).catch(handleError)
|
||||
|
||||
await router.push({ path: `/instance/${encodeURIComponent(id)}` })
|
||||
installModal.value.hide()
|
||||
creatingInstance.value = false
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import {
|
||||
find_jre_8_jres,
|
||||
get_all_jre,
|
||||
} from '@/helpers/jre.js'
|
||||
import { handleError } from '@/store/notifications.js'
|
||||
|
||||
const chosenInstallOptions = ref([])
|
||||
const detectJavaModal = ref(null)
|
||||
@@ -52,14 +53,14 @@ defineExpose({
|
||||
show: async (version, currentSelectedJava) => {
|
||||
if (version <= 8 && !!version) {
|
||||
console.log(version)
|
||||
chosenInstallOptions.value = await find_jre_8_jres()
|
||||
chosenInstallOptions.value = await find_jre_8_jres().catch(handleError)
|
||||
} else if (version >= 18) {
|
||||
chosenInstallOptions.value = await find_jre_18plus_jres()
|
||||
chosenInstallOptions.value = await find_jre_18plus_jres().catch(handleError)
|
||||
} else if (version) {
|
||||
chosenInstallOptions.value = await find_jre_17_jres()
|
||||
chosenInstallOptions.value = await find_jre_17_jres().catch(handleError)
|
||||
} else {
|
||||
console.log('get all')
|
||||
chosenInstallOptions.value = await get_all_jre()
|
||||
chosenInstallOptions.value = await get_all_jre().catch(handleError)
|
||||
}
|
||||
|
||||
currentSelected.value = currentSelectedJava
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="toggle-setting">
|
||||
<input
|
||||
:disabled="props.disabled"
|
||||
:value="props.modelValue.path"
|
||||
:value="props.modelValue ? props.modelValue.path : ''"
|
||||
type="text"
|
||||
class="installation-input"
|
||||
:placeholder="placeholder ?? '/path/to/java'"
|
||||
@@ -25,7 +25,7 @@
|
||||
Auto Detect
|
||||
</Button>
|
||||
<Button :disabled="props.disabled" @click="handleJavaFileInput()">
|
||||
<BrowseIcon />
|
||||
<FolderSearchIcon />
|
||||
Browse
|
||||
</Button>
|
||||
<Button :disabled="props.disabled" @click="testJava">
|
||||
@@ -43,8 +43,15 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Button, SearchIcon, PlayIcon, CheckIcon, XIcon, AnimatedLogo } from 'omorphia'
|
||||
import { BrowseIcon } from '@/assets/icons'
|
||||
import {
|
||||
Button,
|
||||
SearchIcon,
|
||||
PlayIcon,
|
||||
CheckIcon,
|
||||
XIcon,
|
||||
AnimatedLogo,
|
||||
FolderSearchIcon,
|
||||
} from 'omorphia'
|
||||
import { get_jre } from '@/helpers/jre.js'
|
||||
import { ref } from 'vue'
|
||||
import { open } from '@tauri-apps/api/dialog'
|
||||
@@ -78,7 +85,7 @@ const testingJava = ref(false)
|
||||
const testingJavaSuccess = ref(null)
|
||||
async function testJava() {
|
||||
testingJava.value = true
|
||||
let result = await get_jre(props.modelValue.path)
|
||||
let result = await get_jre(props.modelValue ? props.modelValue.path : '')
|
||||
testingJava.value = false
|
||||
testingJavaSuccess.value = !!result
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
{{ currentProcesses[0].metadata.name }}
|
||||
</span>
|
||||
<Button icon-only class="icon-button stop" @click="stop()">
|
||||
<StopIcon />
|
||||
<StopCircleIcon />
|
||||
</Button>
|
||||
<Button icon-only class="icon-button" @click="goToTerminal()">
|
||||
<TerminalIcon />
|
||||
<TerminalSquareIcon />
|
||||
</Button>
|
||||
<Button
|
||||
v-if="currentLoadingBars.length > 0"
|
||||
@@ -47,8 +47,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Button, DownloadIcon, Card } from 'omorphia'
|
||||
import { StopIcon, TerminalIcon } from '@/assets/icons'
|
||||
import { Button, DownloadIcon, Card, StopCircleIcon, TerminalSquareIcon } from 'omorphia'
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import {
|
||||
get_all_running_profiles as getRunningProfiles,
|
||||
@@ -59,20 +58,21 @@ import { loading_listener, process_listener } from '@/helpers/events'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { progress_bars_list } from '@/helpers/state.js'
|
||||
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
||||
import { handleError } from '@/store/notifications.js'
|
||||
|
||||
const router = useRouter()
|
||||
const card = ref(null)
|
||||
const infoButton = ref(null)
|
||||
const showCard = ref(false)
|
||||
|
||||
const currentProcesses = ref(await getRunningProfiles())
|
||||
const currentProcesses = ref(await getRunningProfiles().catch(handleError))
|
||||
|
||||
await process_listener(async () => {
|
||||
await refresh()
|
||||
})
|
||||
|
||||
const refresh = async () => {
|
||||
currentProcesses.value = await getRunningProfiles()
|
||||
currentProcesses.value = await getRunningProfiles().catch(handleError)
|
||||
}
|
||||
|
||||
const stop = async () => {
|
||||
@@ -89,7 +89,7 @@ const goToTerminal = () => {
|
||||
router.push(`/instance/${encodeURIComponent(currentProcesses.value[0].path)}/logs`)
|
||||
}
|
||||
|
||||
const currentLoadingBars = ref(Object.values(await progress_bars_list()))
|
||||
const currentLoadingBars = ref(Object.values(await progress_bars_list().catch(handleError)))
|
||||
|
||||
await loading_listener(async () => {
|
||||
await refreshInfo()
|
||||
@@ -97,7 +97,7 @@ await loading_listener(async () => {
|
||||
|
||||
const refreshInfo = async () => {
|
||||
const currentLoadingBarCount = currentLoadingBars.value.length
|
||||
currentLoadingBars.value = Object.values(await progress_bars_list())
|
||||
currentLoadingBars.value = Object.values(await progress_bars_list().catch(handleError))
|
||||
if (currentLoadingBars.value.length === 0) {
|
||||
showCard.value = false
|
||||
} else if (currentLoadingBarCount < currentLoadingBars.value.length) {
|
||||
@@ -106,7 +106,6 @@ const refreshInfo = async () => {
|
||||
}
|
||||
|
||||
const handleClickOutside = (event) => {
|
||||
console.log('clicked outside from appbar')
|
||||
if (
|
||||
card.value &&
|
||||
infoButton.value.$el !== event.target &&
|
||||
|
||||
@@ -77,12 +77,10 @@ import { ref } from 'vue'
|
||||
import { add_project_from_version as installMod, list } from '@/helpers/profile.js'
|
||||
import { install as packInstall } from '@/helpers/pack.js'
|
||||
import { installVersionDependencies } from '@/helpers/utils.js'
|
||||
import { ofetch } from 'ofetch'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useFetch } from '@/helpers/fetch.js'
|
||||
import { handleError } from '@/store/notifications.js'
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const props = defineProps({
|
||||
backgroundImage: {
|
||||
type: String,
|
||||
@@ -130,8 +128,9 @@ const installed = ref(
|
||||
|
||||
async function install() {
|
||||
installing.value = true
|
||||
const versions = await ofetch(
|
||||
`https://api.modrinth.com/v2/project/${props.project.project_id}/version`
|
||||
const versions = await useFetch(
|
||||
`https://api.modrinth.com/v2/project/${props.project.project_id}/version`,
|
||||
'project versions'
|
||||
)
|
||||
let queuedVersionData
|
||||
|
||||
@@ -146,15 +145,16 @@ async function install() {
|
||||
}
|
||||
|
||||
if (props.project.project_type === 'modpack') {
|
||||
const packs = Object.values(await list())
|
||||
const packs = Object.values(await list().catch(handleError))
|
||||
if (
|
||||
packs.length === 0 ||
|
||||
!packs
|
||||
.map((value) => value.metadata)
|
||||
.find((pack) => pack.linked_data?.project_id === props.project.project_id)
|
||||
) {
|
||||
let id = await packInstall(queuedVersionData.id, props.project.title, props.project.icon_url)
|
||||
await router.push({ path: `/instance/${encodeURIComponent(id)}` })
|
||||
await packInstall(queuedVersionData.id, props.project.title, props.project.icon_url).catch(
|
||||
handleError
|
||||
)
|
||||
} else {
|
||||
props.confirmModal.show(queuedVersionData.id)
|
||||
}
|
||||
@@ -170,7 +170,7 @@ async function install() {
|
||||
installing.value = false
|
||||
return
|
||||
} else {
|
||||
await installMod(props.instance.path, queuedVersionData.id)
|
||||
await installMod(props.instance.path, queuedVersionData.id).catch(handleError)
|
||||
installVersionDependencies(props.instance, queuedVersionData)
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user