Better error handling, fix some more broken OG links

This commit is contained in:
Geometrically
2021-01-01 09:09:53 -07:00
parent 9de5950f4d
commit a0b6a3bed6
10 changed files with 298 additions and 241 deletions

View File

@@ -1,15 +1,25 @@
<template> <template>
<div class="main"> <div class="main">
<h1>{{ error.message }}</h1> <div class="container">
<NuxtLink to="/"> <NuxtLink to="/">
<h2>{{ error.message }}</h2>
<p>
An error occurred! Click this text to go back home, and find your way An error occurred! Click this text to go back home, and find your way
back! back!
</p>
</NuxtLink> </NuxtLink>
</div> </div>
<m-footer class="footer" centered />
</div>
</template> </template>
<script> <script>
import MFooter from '@/components/MFooter'
export default { export default {
components: {
MFooter,
},
props: { props: {
error: { error: {
type: Object, type: Object,
@@ -29,8 +39,12 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.main { .main {
margin: 0 auto; margin: var(--spacing-card-sm) auto;
max-width: 800px; max-width: 800px;
text-align: center; }
.container {
@extend %card;
padding: var(--spacing-card-md) var(--spacing-card-lg);
} }
</style> </style>

View File

@@ -25,7 +25,6 @@
<div class="right hero-image"> <div class="right hero-image">
<video <video
src="~/assets/images/search.mp4" src="~/assets/images/search.mp4"
alt="search"
loading="lazy" loading="lazy"
loop loop
muted muted

View File

@@ -171,7 +171,7 @@ export default {
{ {
hid: 'og:url', hid: 'og:url',
name: 'og:url', name: 'og:url',
content: `https://modrinth.com/privacy`, content: `https://modrinth.com/legal/privacy`,
}, },
], ],
}, },

View File

@@ -183,7 +183,7 @@ export default {
{ {
hid: 'og:url', hid: 'og:url',
name: 'og:url', name: 'og:url',
content: `https://modrinth.com/tos`, content: `https://modrinth.com/legal/terms`,
}, },
], ],
}, },

View File

@@ -282,6 +282,7 @@ export default {
}, },
} }
try {
const [ const [
mod, mod,
availableCategories, availableCategories,
@@ -332,6 +333,12 @@ export default {
license_url: mod.license.url, license_url: mod.license.url,
// availableDonationPlatforms, // availableDonationPlatforms,
} }
} catch {
data.error({
statusCode: 404,
message: 'Mod not found',
})
}
}, },
data() { data() {
return { return {

View File

@@ -28,6 +28,7 @@ export default {
}, },
} }
try {
const mod = ( const mod = (
await axios.get( await axios.get(
`https://api.modrinth.com/api/v1/mod/${data.params.id}`, `https://api.modrinth.com/api/v1/mod/${data.params.id}`,
@@ -72,6 +73,12 @@ export default {
members, members,
currentMember, currentMember,
} }
} catch {
data.error({
statusCode: 404,
message: 'Mod not found',
})
}
}, },
data() { data() {
return { return {

View File

@@ -219,6 +219,7 @@ export default {
}, },
} }
try {
const mod = ( const mod = (
await axios.get( await axios.get(
`https://api.modrinth.com/api/v1/mod/${data.params.id}`, `https://api.modrinth.com/api/v1/mod/${data.params.id}`,
@@ -268,6 +269,12 @@ export default {
members, members,
currentMember, currentMember,
} }
} catch {
data.error({
statusCode: 404,
message: 'Mod not found',
})
}
}, },
data() { data() {
return { return {

View File

@@ -126,6 +126,7 @@ export default {
}, },
} }
try {
const mod = ( const mod = (
await axios.get( await axios.get(
`https://api.modrinth.com/api/v1/mod/${data.params.id}`, `https://api.modrinth.com/api/v1/mod/${data.params.id}`,
@@ -182,6 +183,12 @@ export default {
primaryFile, primaryFile,
currentMember, currentMember,
} }
} catch {
data.error({
statusCode: 404,
message: 'Version not found',
})
}
}, },
data() { data() {
return { return {

View File

@@ -232,6 +232,7 @@ export default {
}, },
} }
try {
const mod = ( const mod = (
await axios.get( await axios.get(
`https://api.modrinth.com/api/v1/mod/${data.params.id}`, `https://api.modrinth.com/api/v1/mod/${data.params.id}`,
@@ -280,6 +281,12 @@ export default {
selectableVersions, selectableVersions,
currentMember, currentMember,
} }
} catch {
data.error({
statusCode: 404,
message: 'Mod not found',
})
}
}, },
data() { data() {
return { return {

View File

@@ -99,6 +99,7 @@ export default {
}, },
} }
try {
let res = await axios.get( let res = await axios.get(
`https://api.modrinth.com/api/v1/user/${data.params.id}`, `https://api.modrinth.com/api/v1/user/${data.params.id}`,
config config
@@ -112,7 +113,9 @@ export default {
) )
if (res.data) { if (res.data) {
res = await axios.get( res = await axios.get(
`https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}`, `https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(
res.data
)}`,
config config
) )
mods = res.data mods = res.data
@@ -122,6 +125,12 @@ export default {
mods, mods,
user, user,
} }
} catch {
data.error({
statusCode: 404,
message: 'User not found',
})
}
}, },
methods: { methods: {
formatNumber(x) { formatNumber(x) {