Skip to content

Commit

Permalink
fix(board): add debugging-info to exceptions in getServerSideProps (#…
Browse files Browse the repository at this point in the history
…1753)

* fix(board): add debugging-info to exceptions in getServerSIdeProps

* chore(board): check that parser is not undefined

* chore(board): set custom error message as part of exception
  • Loading branch information
SelmaBergstrand authored Nov 28, 2024
1 parent f0ab0cb commit 073edcd
Showing 1 changed file with 47 additions and 21 deletions.
68 changes: 47 additions & 21 deletions tavla/pages/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,61 @@ import { TGetQuayQuery, TStopPlaceQuery } from 'graphql/index'
import { isUnsupportedBrowser } from 'utils/browserDetection'
import { GetServerSideProps } from 'next'
import { SSRQuayQuery, SSRStopPlaceQuery } from 'graphql/ssrQueries'
import * as Sentry from '@sentry/nextjs'

export const getServerSideProps: GetServerSideProps = async (context) => {
const { params, req } = context
const { id } = params as { id: string }
const ua = req.headers['user-agent'] || ''
const fetchBoardServerSide = isUnsupportedBrowser(ua)
try {
const { params, req } = context
if (!params || !req) {
Sentry.captureMessage('Missing params or req in getServerSideProps')
return {
notFound: true,
}
}
const { id } = params as { id: string }
const ua = req.headers['user-agent'] || ''
const fetchBoardServerSide = isUnsupportedBrowser(ua)

const board: TBoard | undefined = await getBoard(id)
if (!id) {
Sentry.captureMessage('Missing board ID in getServerSideProps')
return {
notFound: true,
}
}

if (!board) {
return {
notFound: true,
const board: TBoard | undefined = await getBoard(id)

if (!board) {
Sentry.captureMessage('Board is undefined in getServerSideProps')
return {
notFound: true,
}
}
}

const organization = await getOrganizationWithBoard(id)
const organization = await getOrganizationWithBoard(id)

let tileData = null
if (fetchBoardServerSide) {
tileData = await getTileData(board)
}
let tileData = null
if (fetchBoardServerSide) {
tileData = await getTileData(board)
}

return {
props: {
board,
organization,
backend_url: getBackendUrl(),
tileData,
},
return {
props: {
board,
organization,
backend_url: getBackendUrl(),
tileData,
},
}
} catch (error) {
Sentry.captureException(error, {
extra: {
message: 'Unknown error occurred in getServerSideProps',
},
})
return {
notFound: true,
}
}
}

Expand Down

0 comments on commit 073edcd

Please sign in to comment.