You've already forked AstralRinth
forked from didirus/AstralRinth
Error handling (#121)
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
</Button>
|
||||
<!--TODO: https://github.com/tauri-apps/tauri/issues/4062 -->
|
||||
<Button class="instance-button" icon-only @click="open({ defaultPath: instance.path })">
|
||||
<OpenFolderIcon />
|
||||
<FolderOpenIcon />
|
||||
</Button>
|
||||
</span>
|
||||
</Card>
|
||||
@@ -82,8 +82,18 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { BoxIcon, SettingsIcon, FileIcon, XIcon, Button, Avatar, Card, Promotion } from 'omorphia'
|
||||
import { PlayIcon, OpenFolderIcon } from '@/assets/icons'
|
||||
import {
|
||||
BoxIcon,
|
||||
SettingsIcon,
|
||||
FileIcon,
|
||||
XIcon,
|
||||
Button,
|
||||
Avatar,
|
||||
Card,
|
||||
Promotion,
|
||||
PlayIcon,
|
||||
FolderOpenIcon,
|
||||
} from 'omorphia'
|
||||
import { get, run } from '@/helpers/profile'
|
||||
import {
|
||||
get_all_running_profile_paths,
|
||||
@@ -95,13 +105,13 @@ import { useRoute } from 'vue-router'
|
||||
import { ref, onUnmounted } from 'vue'
|
||||
import { convertFileSrc } from '@tauri-apps/api/tauri'
|
||||
import { open } from '@tauri-apps/api/dialog'
|
||||
import { useBreadcrumbs, useLoading, useSearch } from '@/store/state'
|
||||
import { handleError, useBreadcrumbs, useLoading, useSearch } from '@/store/state'
|
||||
|
||||
const route = useRoute()
|
||||
const searchStore = useSearch()
|
||||
const breadcrumbs = useBreadcrumbs()
|
||||
|
||||
const instance = ref(await get(route.params.id))
|
||||
const instance = ref(await get(route.params.id).catch(handleError))
|
||||
|
||||
searchStore.instanceContext = instance.value
|
||||
breadcrumbs.setName('Instance', instance.value.metadata.name)
|
||||
@@ -118,13 +128,13 @@ const loading = ref(false)
|
||||
|
||||
const startInstance = async () => {
|
||||
loading.value = true
|
||||
uuid.value = await run(route.params.id)
|
||||
uuid.value = await run(route.params.id).catch(handleError)
|
||||
loading.value = false
|
||||
playing.value = true
|
||||
}
|
||||
|
||||
const checkProcess = async () => {
|
||||
const runningPaths = await get_all_running_profile_paths()
|
||||
const runningPaths = await get_all_running_profile_paths().catch(handleError)
|
||||
if (runningPaths.includes(instance.value.path)) {
|
||||
playing.value = true
|
||||
return
|
||||
@@ -141,10 +151,10 @@ const stopInstance = async () => {
|
||||
|
||||
try {
|
||||
if (!uuid.value) {
|
||||
const uuids = await get_uuids_by_profile_path(instance.value.path)
|
||||
const uuids = await get_uuids_by_profile_path(instance.value.path).catch(handleError)
|
||||
uuid.value = uuids[0] // populate Uuid to listen for in the process_listener
|
||||
uuids.forEach(async (u) => await kill_by_uuid(u))
|
||||
} else await kill_by_uuid(uuid.value)
|
||||
uuids.forEach(async (u) => await kill_by_uuid(u).catch(handleError))
|
||||
} else await kill_by_uuid(uuid.value).catch(handleError)
|
||||
} catch (err) {
|
||||
// Theseus currently throws:
|
||||
// "Error launching Minecraft: Minecraft exited with non-zero code 1" error
|
||||
@@ -155,7 +165,7 @@ const stopInstance = async () => {
|
||||
|
||||
const unlistenProfiles = await profile_listener(async (event) => {
|
||||
if (event.path === route.params.id) {
|
||||
instance.value = await get(route.params.id)
|
||||
instance.value = await get(route.params.id).catch(handleError)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ import calendar from 'dayjs/plugin/calendar'
|
||||
import { get_stdout_by_uuid, get_uuids_by_profile_path } from '@/helpers/process.js'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { process_listener } from '@/helpers/events.js'
|
||||
import { handleError } from '@/store/notifications.js'
|
||||
|
||||
dayjs.extend(calendar)
|
||||
|
||||
@@ -68,19 +69,19 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
async function getLiveLog() {
|
||||
const uuids = await get_uuids_by_profile_path(route.params.id)
|
||||
const uuids = await get_uuids_by_profile_path(route.params.id).catch(handleError)
|
||||
let returnValue
|
||||
if (uuids.length === 0) {
|
||||
returnValue = 'No live game detected. \nStart your game to proceed'
|
||||
} else {
|
||||
returnValue = await get_stdout_by_uuid(uuids[0])
|
||||
returnValue = await get_stdout_by_uuid(uuids[0]).catch(handleError)
|
||||
}
|
||||
|
||||
return { name: 'Live Log', stdout: returnValue, live: true }
|
||||
}
|
||||
|
||||
async function getLogs() {
|
||||
return (await get_logs(props.instance.uuid, true)).reverse().map((log) => {
|
||||
return (await get_logs(props.instance.uuid, true).catch(handleError)).reverse().map((log) => {
|
||||
log.name = dayjs(
|
||||
log.datetime_string.slice(0, 8) + 'T' + log.datetime_string.slice(9)
|
||||
).calendar()
|
||||
@@ -116,7 +117,7 @@ watch(selectedLogIndex, async (newIndex) => {
|
||||
logs.value[newIndex].stdout = await get_stdout_by_datetime(
|
||||
props.instance.uuid,
|
||||
logs.value[newIndex].datetime_string
|
||||
)
|
||||
).catch(handleError)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -124,7 +125,10 @@ const deleteLog = async () => {
|
||||
if (logs.value[selectedLogIndex.value] && selectedLogIndex.value !== 0) {
|
||||
let deleteIndex = selectedLogIndex.value
|
||||
selectedLogIndex.value = deleteIndex - 1
|
||||
await delete_logs_by_datetime(props.instance.uuid, logs.value[deleteIndex].datetime_string)
|
||||
await delete_logs_by_datetime(
|
||||
props.instance.uuid,
|
||||
logs.value[deleteIndex].datetime_string
|
||||
).catch(handleError)
|
||||
await setLogs()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ import {
|
||||
update_all,
|
||||
update_project,
|
||||
} from '@/helpers/profile.js'
|
||||
import { handleError } from '@/store/notifications.js'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -200,7 +201,7 @@ async function updateAll() {
|
||||
}
|
||||
}
|
||||
|
||||
const paths = await update_all(props.instance.path)
|
||||
const paths = await update_all(props.instance.path).catch(handleError)
|
||||
|
||||
for (const [oldVal, newVal] of Object.entries(paths)) {
|
||||
const index = projects.value.findIndex((x) => x.path === oldVal)
|
||||
@@ -219,7 +220,7 @@ async function updateAll() {
|
||||
|
||||
async function updateProject(mod) {
|
||||
mod.updating = true
|
||||
mod.path = await update_project(props.instance.path, mod.path)
|
||||
mod.path = await update_project(props.instance.path, mod.path).catch(handleError)
|
||||
mod.updating = false
|
||||
|
||||
mod.outdated = false
|
||||
@@ -228,11 +229,11 @@ async function updateProject(mod) {
|
||||
}
|
||||
|
||||
async function toggleDisableMod(mod) {
|
||||
mod.path = await toggle_disable_project(props.instance.path, mod.path)
|
||||
mod.path = await toggle_disable_project(props.instance.path, mod.path).catch(handleError)
|
||||
}
|
||||
|
||||
async function removeMod(mod) {
|
||||
await remove_project(props.instance.path, mod.path)
|
||||
await remove_project(props.instance.path, mod.path).catch(handleError)
|
||||
projects.value = projects.value.filter((x) => mod.path !== x.path)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -217,8 +217,8 @@ import {
|
||||
DropdownSelect,
|
||||
XIcon,
|
||||
SaveIcon,
|
||||
HammerIcon,
|
||||
} from 'omorphia'
|
||||
import { HammerIcon } from '@/assets/icons'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { edit, edit_icon, get_optimal_jre_key, install, remove } from '@/helpers/profile.js'
|
||||
import { computed, readonly, ref, shallowRef, watch } from 'vue'
|
||||
@@ -229,6 +229,7 @@ import { convertFileSrc } from '@tauri-apps/api/tauri'
|
||||
import { open } from '@tauri-apps/api/dialog'
|
||||
import { get_fabric_versions, get_forge_versions, get_quilt_versions } from '@/helpers/metadata.js'
|
||||
import { get_game_versions, get_loaders } from '@/helpers/tags.js'
|
||||
import { handleError } from '@/store/notifications.js'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -244,7 +245,7 @@ const icon = ref(props.instance.metadata.icon)
|
||||
|
||||
async function resetIcon() {
|
||||
icon.value = null
|
||||
await edit_icon(props.instance.path, null)
|
||||
await edit_icon(props.instance.path, null).catch(handleError)
|
||||
}
|
||||
|
||||
async function setIcon() {
|
||||
@@ -261,15 +262,15 @@ async function setIcon() {
|
||||
if (!value) return
|
||||
|
||||
icon.value = value
|
||||
await edit_icon(props.instance.path, icon.value)
|
||||
await edit_icon(props.instance.path, icon.value).catch(handleError)
|
||||
}
|
||||
|
||||
const globalSettings = await get()
|
||||
const globalSettings = await get().catch(handleError)
|
||||
|
||||
const javaSettings = props.instance.java ?? {}
|
||||
|
||||
const overrideJavaInstall = ref(!!javaSettings.override_version)
|
||||
const optimalJava = readonly(await get_optimal_jre_key(props.instance.path))
|
||||
const optimalJava = readonly(await get_optimal_jre_key(props.instance.path).catch(handleError))
|
||||
const javaInstall = ref(optimalJava ?? javaSettings.override_version ?? { path: '', version: '' })
|
||||
|
||||
const overrideJavaArgs = ref(!!javaSettings.extra_arguments)
|
||||
@@ -282,7 +283,7 @@ const envVars = ref(
|
||||
|
||||
const overrideMemorySettings = ref(!!props.instance.memory)
|
||||
const memory = ref(props.instance.memory ?? globalSettings.memory)
|
||||
const maxMemory = (await get_max_memory()) / 1024
|
||||
const maxMemory = (await get_max_memory().catch(handleError)) / 1024
|
||||
|
||||
const overrideWindowSettings = ref(!!props.instance.resolution)
|
||||
const resolution = ref(props.instance.resolution ?? globalSettings.game_resolution)
|
||||
@@ -356,14 +357,14 @@ const repairing = ref(false)
|
||||
|
||||
async function repairProfile() {
|
||||
repairing.value = true
|
||||
await install(props.instance.path)
|
||||
await install(props.instance.path).catch(handleError)
|
||||
repairing.value = false
|
||||
}
|
||||
|
||||
const removing = ref(false)
|
||||
async function removeProfile() {
|
||||
removing.value = true
|
||||
await remove(props.instance.path)
|
||||
await remove(props.instance.path).catch(handleError)
|
||||
removing.value = false
|
||||
|
||||
await router.push({ path: '/' })
|
||||
@@ -374,17 +375,18 @@ const showSnapshots = ref(false)
|
||||
|
||||
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')
|
||||
|
||||
@@ -449,7 +451,7 @@ async function saveGvLoaderEdits() {
|
||||
if (loader.value !== 'vanilla') {
|
||||
editProfile.metadata.loader_version = selectableLoaderVersions.value[loaderVersionIndex.value]
|
||||
}
|
||||
await edit(props.instance.path, editProfile)
|
||||
await edit(props.instance.path, editProfile).catch(handleError)
|
||||
await repairProfile()
|
||||
|
||||
editing.value = false
|
||||
|
||||
Reference in New Issue
Block a user