Skip to content

Commit 8237644

Browse files
authored
Prevent 404 errors from being sent to Sentry (baserow#4836)
1 parent 3ea431e commit 8237644

File tree

20 files changed

+125
-61
lines changed

20 files changed

+125
-61
lines changed

backend/uv.lock

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

premium/web-frontend/modules/baserow_premium/pages/admin/license.vue

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,19 +216,26 @@ const router = useRouter()
216216
const { $client, $registry } = useNuxtApp()
217217
218218
// Fetch license data
219-
const { data } = await useAsyncData(`license-${route.params.id}`, async () => {
220-
try {
221-
const { data: licenseData } = await LicenseService($client).fetch(
222-
route.params.id
223-
)
224-
return licenseData
225-
} catch {
226-
throw createError({
227-
statusCode: 404,
228-
message: 'The license was not found.',
229-
})
219+
const { data, error } = await useAsyncData(
220+
`license-${route.params.id}`,
221+
async () => {
222+
try {
223+
const { data: licenseData } = await LicenseService($client).fetch(
224+
route.params.id
225+
)
226+
return licenseData
227+
} catch {
228+
throw createError({
229+
statusCode: 404,
230+
message: 'The license was not found.',
231+
})
232+
}
230233
}
231-
})
234+
)
235+
236+
if (error.value) {
237+
throw error.value
238+
}
232239
233240
const license = computed(() => data.value)
234241

premium/web-frontend/modules/baserow_premium/pages/admin/licenses.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const { $client, $registry, $i18n } = useNuxtApp()
169169
useHead({ title: $i18n.t('licenses.titleLicenses') })
170170
171171
// Fetch data using useAsyncData and return the values from the callback
172-
const { data } = await useAsyncData('licensesPage', async () => {
172+
const { data, error } = await useAsyncData('licensesPage', async () => {
173173
try {
174174
const [{ data: instanceData }, { data: licensesData }] = await Promise.all([
175175
SettingsService($client).getInstanceID(),
@@ -183,11 +183,16 @@ const { data } = await useAsyncData('licensesPage', async () => {
183183
} catch (e) {
184184
throw createError({
185185
statusCode: 400,
186-
statusMessage: 'Something went wrong while fetching the licenses.',
186+
message: 'Something went wrong while fetching the licenses.',
187+
fatal: true,
187188
})
188189
}
189190
})
190191
192+
if (error.value) {
193+
throw error.value
194+
}
195+
191196
const licenses = computed(() => data.value?.licenses || [])
192197
const instanceId = computed(() => data.value?.instanceId || '')
193198

web-frontend/modules/automation/pages/automationWorkflow.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const automationApplicationType = $registry.get(
108108
AutomationApplicationType.getType()
109109
)
110110
111-
const { data: pageData } = await useAsyncData(
111+
const { data: pageData, error } = await useAsyncData(
112112
() => `automation-workflow-${automationId.value}-${workflowId.value}`,
113113
async () => {
114114
try {
@@ -151,6 +151,10 @@ const { data: pageData } = await useAsyncData(
151151
}
152152
)
153153
154+
if (error.value) {
155+
throw error.value
156+
}
157+
154158
// Computed properties from async data
155159
const automation = computed(() => pageData.value?.automation ?? null)
156160
const workspace = computed(() => pageData.value?.workspace ?? null)

web-frontend/modules/builder/middleware/selectWorkspaceBuilderPage.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
2525
throw createError({
2626
statusCode: 404,
2727
message: $i18n.t('pageEditor.pageNotFound'),
28-
fatal: false,
2928
})
3029
}
3130
})

web-frontend/modules/builder/pages/pageEditor.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,7 @@ const {
104104
)
105105
106106
if (pageError.value) {
107-
// If we have an error we want to display it.
108-
if (pageError.value.statusCode === 404) {
109-
showError(pageError.value)
110-
} else {
111-
throw pageError.value
112-
}
107+
throw pageError.value
113108
}
114109
115110
const workspace = computed(() => pageData.value.workspace)

web-frontend/modules/builder/pages/publicPage.vue

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const {
9797
} catch (e) {
9898
throw createError({
9999
statusCode: 404,
100-
statusMessage: $i18n.t('publicPage.siteNotFound'),
100+
message: $i18n.t('publicPage.siteNotFound'),
101101
})
102102
}
103103
@@ -173,7 +173,7 @@ const {
173173
if (authError) {
174174
throw createError({
175175
statusCode: authError.code,
176-
statusMessage: authError.message,
176+
message: authError.message,
177177
})
178178
}
179179
}
@@ -190,7 +190,7 @@ const {
190190
if (!found) {
191191
throw createError({
192192
statusCode: 404,
193-
statusMessage: $i18n.t('publicPage.pageNotFound'),
193+
message: $i18n.t('publicPage.pageNotFound'),
194194
})
195195
}
196196
@@ -199,7 +199,7 @@ const {
199199
if (pageFound.shared) {
200200
throw createError({
201201
statusCode: 404,
202-
statusMessage: $i18n.t('publicPage.pageNotFound'),
202+
message: $i18n.t('publicPage.pageNotFound'),
203203
})
204204
}
205205
@@ -288,12 +288,7 @@ const {
288288
)
289289
290290
if (error.value) {
291-
// If we have an error we want to display it.
292-
if (error.value.statusCode === 404) {
293-
showError(error.value)
294-
} else {
295-
throw error.value
296-
}
291+
throw error.value
297292
}
298293
299294
const workspace = computed(() => asyncDataResult.value?.workspace)

web-frontend/modules/core/middleware/urlCheck.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default defineNuxtRouteMiddleware(() => {
3535
hideBackButton: true,
3636
message: translate('urlCheck.invalidUrlEnvVarTitle', { name }),
3737
content: translate('urlCheck.invalidUrlEnvVarDescription', { name }),
38+
fatal: true,
3839
})
3940
}
4041
}

web-frontend/modules/core/module.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export default defineNuxtModule({
112112
)
113113

114114
addPlugin(resolve('plugins/store.js'))
115+
addPlugin(resolve('plugins/errorHandler.js'))
115116
addPlugin(resolve('plugins/filters.js'))
116117
addPlugin(resolve('plugins/vuexState.js'))
117118
addPlugin(resolve('plugin.js'))

web-frontend/modules/core/pages/notificationRedirect.vue

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@ const notificationId = route.params.notificationId
1515
const { data: notification, error: loadError } = await useAsyncData(
1616
() => `notification:${workspaceId}:${notificationId}`,
1717
async () => {
18-
const { data } = await notificationService(nuxtApp.$client).markAsRead(
19-
workspaceId,
20-
notificationId
21-
)
22-
return data
18+
try {
19+
const { data } = await notificationService(nuxtApp.$client).markAsRead(
20+
workspaceId,
21+
notificationId
22+
)
23+
return data
24+
} catch {
25+
throw createError({
26+
statusCode: 404,
27+
message: 'Notification not found.',
28+
})
29+
}
2330
}
2431
)
2532
2633
if (loadError.value || !notification.value) {
27-
throw createError({
28-
statusCode: 404,
29-
statusMessage: 'Notification not found.',
30-
})
34+
throw loadError.value
3135
}
3236
3337
const notificationType = nuxtApp.$registry.get(
@@ -39,7 +43,7 @@ const redirectParams = notificationType.getRoute(notification.value.data)
3943
if (!redirectParams) {
4044
throw createError({
4145
statusCode: 404,
42-
statusMessage: 'Notification has no route.',
46+
message: 'Notification has no route.',
4347
})
4448
}
4549

0 commit comments

Comments
 (0)