1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-11 16:01:20 +00:00

show error when the server responds with a 429 error

This commit is contained in:
Bram Wiepjes 2021-03-25 23:33:58 +01:00
parent 3c2269b6b1
commit 3d5432c722
2 changed files with 29 additions and 1 deletions
web-frontend/modules
core/plugins
database/pages

View file

@ -88,6 +88,15 @@ class ErrorHandler {
return this.response !== undefined && this.response.status === 404
}
/**
* Returns true if the response status code is equal to not found (429) which
* means that the user is sending too much requests to the server.
* @return {boolean}
*/
isTooManyRequests() {
return this.response !== undefined && this.response.status === 429
}
/**
* Return true if there is a network error.
* @return {boolean}
@ -142,11 +151,25 @@ class ErrorHandler {
)
}
/**
* Returns a standard network error message. For example if the API server
* could not be reached.
*/
getTooManyRequestsError() {
return new ResponseErrorMessage(
'Too many requests',
'You are sending too many requests to the server. Please wait a moment.'
)
}
/**
* If there is an error or the requested detail is not found an error
* message related to the problem is returned.
*/
getMessage(name = null, specificErrorMap = null) {
if (this.isTooManyRequests()) {
return this.getTooManyRequestsError()
}
if (this.hasNetworkError()) {
return this.getNetworkErrorMessage()
}

View file

@ -90,6 +90,7 @@
import { mapState } from 'vuex'
import { StoreItemLookupError } from '@baserow/modules/core/errors'
import { notifyIf } from '@baserow/modules/core/utils/error'
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'
@ -253,7 +254,11 @@ export default {
async refresh(event) {
this.viewLoading = true
const type = this.$registry.get('view', this.view.type)
await type.refresh({ store: this.$store }, this.view)
try {
await type.refresh({ store: this.$store }, this.view)
} catch (error) {
notifyIf(error)
}
if (
Object.prototype.hasOwnProperty.call(this.$refs, 'view') &&
Object.prototype.hasOwnProperty.call(this.$refs.view, 'refresh')