mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-02 22:51:34 -06:00
add types for axios errors.
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component } from 'vue-property-decorator'
|
||||
import { AxiosError } from 'axios'
|
||||
|
||||
@Component
|
||||
export default class Pull extends Vue {
|
||||
@@ -74,10 +75,11 @@ export default class Pull extends Vue {
|
||||
try {
|
||||
await this.$store.dispatch('PULL_START', this.nekoImage)
|
||||
} catch(e) {
|
||||
if (e.response) {
|
||||
const response = (e as AxiosError).response
|
||||
if (response) {
|
||||
this.$swal({
|
||||
title: 'Server error',
|
||||
text: e.response.data,
|
||||
text: response.data,
|
||||
icon: 'error',
|
||||
})
|
||||
} else {
|
||||
@@ -98,10 +100,11 @@ export default class Pull extends Vue {
|
||||
try {
|
||||
await this.$store.dispatch('PULL_STOP')
|
||||
} catch(e) {
|
||||
if (e.response) {
|
||||
const response = (e as AxiosError).response
|
||||
if (response) {
|
||||
this.$swal({
|
||||
title: 'Server error',
|
||||
text: e.response.data,
|
||||
text: response.data,
|
||||
icon: 'error',
|
||||
})
|
||||
} else {
|
||||
@@ -128,7 +131,12 @@ export default class Pull extends Vue {
|
||||
try {
|
||||
await this.$store.dispatch('PULL_STATUS')
|
||||
} catch(e) {
|
||||
console.error(e)
|
||||
const response = (e as AxiosError).response
|
||||
if (response) {
|
||||
console.error('Server error', response.data)
|
||||
} else {
|
||||
console.error('Network error', String(e))
|
||||
}
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component, Prop } from 'vue-property-decorator'
|
||||
import { AxiosError } from 'axios'
|
||||
|
||||
@Component
|
||||
export default class RoomActionBtn extends Vue {
|
||||
@@ -102,10 +103,11 @@ export default class RoomActionBtn extends Vue {
|
||||
icon: 'success',
|
||||
})
|
||||
} catch(e) {
|
||||
if (e.response) {
|
||||
const response = (e as AxiosError).response
|
||||
if (response) {
|
||||
this.$swal({
|
||||
title: 'Server error',
|
||||
text: e.response.data,
|
||||
text: response.data,
|
||||
icon: 'error',
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -206,6 +206,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
|
||||
import { AxiosError } from 'axios'
|
||||
import RoomLink from './RoomLink.vue'
|
||||
|
||||
import {
|
||||
@@ -247,10 +248,11 @@ export default class RoomInfo extends Vue {
|
||||
this.LoadStats()
|
||||
}
|
||||
} catch(e) {
|
||||
if (e.response) {
|
||||
const response = (e as AxiosError).response
|
||||
if (response) {
|
||||
this.$swal({
|
||||
title: 'Server error',
|
||||
text: e.response.data,
|
||||
text: response.data,
|
||||
icon: 'error',
|
||||
})
|
||||
} else {
|
||||
@@ -288,7 +290,12 @@ export default class RoomInfo extends Vue {
|
||||
this.stats = stats
|
||||
this.statsErr = ""
|
||||
} catch(e) {
|
||||
this.statsErr = e
|
||||
const response = (e as AxiosError).response
|
||||
if (response) {
|
||||
this.statsErr = `Server error: ${response.data}`
|
||||
} else {
|
||||
this.statsErr = `Network error: ${String(e)}`
|
||||
}
|
||||
} finally {
|
||||
this.statsLoading = false
|
||||
}
|
||||
|
||||
@@ -492,6 +492,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component, Ref, Watch } from 'vue-property-decorator'
|
||||
import { AxiosError } from 'axios'
|
||||
import { randomPassword } from '@/utils/random'
|
||||
|
||||
import {
|
||||
@@ -700,10 +701,11 @@ export default class RoomsCreate extends Vue {
|
||||
this.Clear()
|
||||
this.$emit('finished', true)
|
||||
} catch(e) {
|
||||
if (e.response) {
|
||||
const response = (e as AxiosError).response
|
||||
if (response) {
|
||||
this.$swal({
|
||||
title: 'Server error',
|
||||
text: e.response.data,
|
||||
text: response.data,
|
||||
icon: 'error',
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -46,9 +46,11 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component } from 'vue-property-decorator'
|
||||
import RoomInfo from '@/components/RoomInfo.vue'
|
||||
import { AxiosError } from 'axios'
|
||||
import { randomPassword } from '@/utils/random'
|
||||
|
||||
import RoomInfo from '@/components/RoomInfo.vue'
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
RoomInfo,
|
||||
@@ -81,10 +83,11 @@ export default class RoomActionBtn extends Vue {
|
||||
this.roomId = entry.id
|
||||
this.dialog = true
|
||||
} catch(e) {
|
||||
if (e.response) {
|
||||
const response = (e as AxiosError).response
|
||||
if (response) {
|
||||
this.$swal({
|
||||
title: 'Server error',
|
||||
text: e.response.data,
|
||||
text: response.data,
|
||||
icon: 'error',
|
||||
})
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user