🐛 Error object not compatible with json parsing of gssp

This commit is contained in:
Meier Lukas
2023-11-14 20:42:17 +01:00
parent c9d1a12299
commit a0efd01d43
2 changed files with 24 additions and 14 deletions

View File

@@ -1,7 +1,13 @@
import { Center, Code, List, Stack, Text, Title } from '@mantine/core';
import Head from 'next/head';
export const DatabaseNotWriteable = ({ error, errorMessage }: { error: any | unknown, errorMessage: string | undefined }) => {
export const DatabaseNotWriteable = ({
stringifiedError,
errorMessage,
}: {
stringifiedError: string | undefined;
errorMessage: string | undefined;
}) => {
return (
<>
<Head>
@@ -30,11 +36,9 @@ export const DatabaseNotWriteable = ({ error, errorMessage }: { error: any | unk
</a>
</List.Item>
</List>
<Code block>{error && JSON.stringify(error)}</Code>
<Code block>{stringifiedError}</Code>
{errorMessage && (
<Code block>{errorMessage}</Code>
)}
{errorMessage && <Code block>{errorMessage}</Code>}
</Stack>
</Center>
</>

View File

@@ -21,8 +21,8 @@ const exec = util.promisify(require('child_process').exec);
export default function OnboardPage({
configSchemaVersions,
databaseNotWriteable,
error,
errorMessage
stringifiedError,
errorMessage,
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
const { fn, colors, colorScheme } = useMantineTheme();
const background = colorScheme === 'dark' ? 'dark.6' : 'gray.1';
@@ -49,7 +49,7 @@ export default function OnboardPage({
</Center>
{databaseNotWriteable == true ? (
<DatabaseNotWriteable error={error} errorMessage={errorMessage} />
<DatabaseNotWriteable stringifiedError={stringifiedError} errorMessage={errorMessage} />
) : (
<>
{onboardingSteps ? (
@@ -117,7 +117,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
...translations,
configSchemaVersions: configSchemaVersions,
databaseNotWriteable: true,
error: error,
errorMessage: 'Database is not writeable',
stringifiedError: JSON.stringify(error),
},
};
}
@@ -128,13 +129,18 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
const { stdout, stderr } = await exec("mount | grep '/data'");
if (stderr.split('\n').length > 1 || stdout.split('\n').length <= 1) {
Consola.error(`Database at '${rawDatabaseUrl}' has not been mounted: ${stdout.replace('\n', '\\n')} ${stderr.replace('\n', '\\n')}`);
Consola.error(
`Database at '${rawDatabaseUrl}' has not been mounted: ${stdout.replace(
'\n',
'\\n'
)} ${stderr.replace('\n', '\\n')}`
);
return {
props: {
...translations,
configSchemaVersions: configSchemaVersions,
databaseNotWriteable: true,
error: `Database at '${rawDatabaseUrl}' is not mounted:\n${stdout}`,
errorMessage: `Database at '${rawDatabaseUrl}' is not mounted:\n${stdout}`,
},
};
}
@@ -146,8 +152,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
...translations,
configSchemaVersions: configSchemaVersions,
databaseNotWriteable: true,
error: error,
errorMessage: errorMessage
stringifiedError: JSON.stringify(error),
errorMessage: errorMessage,
},
};
}
@@ -160,7 +166,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
props: {
...translations,
configSchemaVersions: configSchemaVersions,
databaseNotWriteable: false
databaseNotWriteable: false,
},
};
};