1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-10 15:47:32 +00:00

Merge branch '303-web-frontend-fails-hard-when-visiting-a-table-page-of-an-unknown-table' into 'develop'

Resolve "Web frontend fails hard when visiting a table page of an unknown table"

Closes 

See merge request 
This commit is contained in:
Bram Wiepjes 2021-02-15 11:26:56 +00:00
commit dcea9bd8b9
6 changed files with 25 additions and 8 deletions
web-frontend/modules

View file

@ -0,0 +1,6 @@
/**
* This error can be raised when trying to find an item within a store that doesn't
* exist. For example when a certain application is expected in a store, but can't
* be found.
*/
export class StoreItemLookupError extends Error {}

View file

@ -1,3 +1,4 @@
import { StoreItemLookupError } from '@baserow/modules/core/errors'
import ApplicationService from '@baserow/modules/core/services/application'
import { clone } from '@baserow/modules/core/utils/object'
@ -124,7 +125,9 @@ export const actions = {
}
if (!this.$registry.exists('application', type)) {
throw new Error(`An application type with type "${type}" doesn't exist.`)
throw new StoreItemLookupError(
`An application type with type "${type}" doesn't exist.`
)
}
const postData = clone(values)
@ -204,7 +207,7 @@ export const actions = {
selectById({ dispatch, getters }, id) {
const application = getters.get(id)
if (application === undefined) {
throw new Error(`Application with id ${id} is not found.`)
throw new StoreItemLookupError(`Application with id ${id} is not found.`)
}
return dispatch('select', application)
},

View file

@ -1,3 +1,4 @@
import { StoreItemLookupError } from '@baserow/modules/core/errors'
import GroupService from '@baserow/modules/core/services/group'
import {
setGroupCookie,
@ -184,7 +185,7 @@ export const actions = {
selectById({ dispatch, getters }, id) {
const group = getters.get(id)
if (group === undefined) {
throw new Error(`Group with id ${id} is not found.`)
throw new StoreItemLookupError(`Group with id ${id} is not found.`)
}
return dispatch('select', group)
},

View file

@ -89,6 +89,7 @@
<script>
import { mapState } from 'vuex'
import { StoreItemLookupError } from '@baserow/modules/core/errors'
import ViewsContext from '@baserow/modules/database/components/view/ViewsContext'
import ViewFilter from '@baserow/modules/database/components/view/ViewFilter'
import ViewSort from '@baserow/modules/database/components/view/ViewSort'
@ -143,7 +144,7 @@ export default {
data.table = table
} catch (e) {
// In case of a network error we want to fail hard.
if (e.response === undefined) {
if (e.response === undefined && !(e instanceof StoreItemLookupError)) {
throw e
}
@ -176,7 +177,7 @@ export default {
await type.fetch({ store }, view)
} catch (e) {
// In case of a network error we want to fail hard.
if (e.response === undefined) {
if (e.response === undefined && !(e instanceof StoreItemLookupError)) {
throw e
}

View file

@ -1,5 +1,6 @@
import axios from 'axios'
import { StoreItemLookupError } from '@baserow/modules/core/errors'
import TableService from '@baserow/modules/database/services/table'
import { DatabaseApplicationType } from '@baserow/modules/database/applicationTypes'
@ -177,13 +178,17 @@ export const actions = {
// Check if the just selected application is a database
if (database.type !== type) {
throw new Error(`The application doesn't have the required ${type} type.`)
throw new StoreItemLookupError(
`The application doesn't have the required ${type} type.`
)
}
// Check if the provided table id is found in the just selected database.
const index = database.tables.findIndex((item) => item.id === tableId)
if (index === -1) {
throw new Error('The table is not found in the selected application.')
throw new StoreItemLookupError(
'The table is not found in the selected application.'
)
}
const table = database.tables[index]

View file

@ -1,5 +1,6 @@
import _ from 'lodash'
import { StoreItemLookupError } from '@baserow/modules/core/errors'
import { uuid } from '@baserow/modules/core/utils/string'
import ViewService from '@baserow/modules/database/services/view'
import FilterService from '@baserow/modules/database/services/filter'
@ -321,7 +322,7 @@ export const actions = {
selectById({ dispatch, getters }, id) {
const view = getters.get(id)
if (view === undefined) {
return new Error(`View with id ${id} is not found.`)
throw new StoreItemLookupError(`View with id ${id} is not found.`)
}
return dispatch('select', view)
},