Skip to content

Commit

Permalink
Attempt to make errors display properly in browser console
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadorequest committed May 27, 2020
1 parent 32ee575 commit 8176ad3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { GetStaticPaths, GetStaticProps, NextPage } from 'next';
import { NextRouter, useRouter } from 'next/router';
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
import React, { useState } from 'react';
import { Alert } from 'reactstrap';
import DefaultLayout from '../../../../../components/pageLayouts/DefaultLayout';
import withApollo from '../../../../../hocs/withApollo';
import { StaticParams } from '../../../../../types/nextjs/StaticParams';
Expand All @@ -18,7 +19,6 @@ import { StaticPropsOutput } from '../../../../../types/nextjs/StaticPropsOutput
import { OnlyBrowserPageProps } from '../../../../../types/pageProps/OnlyBrowserPageProps';
import { SSGPageProps } from '../../../../../types/pageProps/SSGPageProps';
import { getCommonStaticPaths, getCommonStaticProps } from '../../../../../utils/nextjs/SSG';
import { Alert } from 'reactstrap';

const fileLabel = 'pages/[locale]/examples/native-features/example-with-ssg-and-fallback/[albumId]';
const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-eslint/no-unused-vars
Expand All @@ -36,6 +36,7 @@ const logger = createLogger({ // eslint-disable-line no-unused-vars,@typescript-
export const getStaticProps: GetStaticProps<SSGPageProps, StaticParams> = async (props: StaticPropsInput): Promise<StaticPropsOutput> => {
const commonStaticProps: StaticPropsOutput = await getCommonStaticProps(props);
const { params: { albumId } } = props;
console.log('getStaticProps.props.params', props.params);
const album = await fetch(`https://jsonplaceholder.typicode.com/albums/${albumId}`)
.then((response) => response.json())
.catch((error) => {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/_error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export type ErrorProps = {
const ErrorPage = (props: ErrorPageProps): JSX.Element => {
const { statusCode, isReadyToRender, err, children = null } = props;
if (process.env.APP_STAGE !== 'production') {
console.debug('ErrorPage - Unexpected error caught, it was captured and sent to Sentry. Error details:', err);
console.debug('ErrorPage - Unexpected error caught, it was captured and sent to Sentry. Error details:'); // eslint-disable-line no-console
console.error(err); // eslint-disable-line no-console
}

// TODO rename to "forceLogTopLevelError" = true and provide false in "DefaultErrorLayout"
Expand Down

0 comments on commit 8176ad3

Please sign in to comment.