-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
434 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Feature: As a user, when the listing API encounters and error, I am presented with an error page | ||
Scenario: User sees an error page when the CTS API encounters errors while rendering a trial description page | ||
And the CTS API is responding with a server error | ||
Given the user navigates to "/v?a=40&id=NCI-2014-01507&loc=0&rl=2" | ||
Then page title on error page is "An error occurred. Please try again later." | ||
And the page contains meta tags with the following names | ||
| name | content | | ||
| prerender-status-code | 500 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/views/ErrorBoundary/GenericErrorPage/GenericErrorPage.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { useEffect } from 'react'; | ||
import { Helmet } from 'react-helmet'; | ||
import { useTracking } from 'react-tracking'; | ||
|
||
import { useAppSettings } from '../../../store/store'; | ||
|
||
const GenericErrorPage = () => { | ||
const [{ canonicalHost }] = useAppSettings(); | ||
const tracking = useTracking(); | ||
|
||
useEffect(() => { | ||
const pageTitle = 'Errors Occurred'; | ||
tracking.trackEvent({ | ||
event: 'ClinicalTrialsSearchApp:Load:Error', | ||
metaTitle: pageTitle, | ||
name: `${canonicalHost.replace(/^(http|https):\/\//g, '')}${ | ||
window.location.pathname | ||
}`, | ||
title: pageTitle, | ||
type: 'PageLoad', | ||
}); | ||
}, []); | ||
|
||
const renderHelmet = () => { | ||
return ( | ||
<Helmet> | ||
<title>Errors Occurred</title> | ||
<meta property="dcterms.subject" content="Error Page" /> | ||
<meta property="dcterms.type" content="errorpage" /> | ||
<meta name="prerender-status-code" content="500" /> | ||
</Helmet> | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
{renderHelmet()} | ||
<div className="error-container"> | ||
<h1>An error occurred. Please try again later.</h1> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default GenericErrorPage; |
10 changes: 10 additions & 0 deletions
10
src/views/ErrorBoundary/GenericErrorPage/GenericErrorPage.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.error-container h1 { | ||
height: 31px; | ||
width: 573px; | ||
color: #606060; | ||
font-family: Montserrat; | ||
font-size: 28px; | ||
font-weight: bold; | ||
letter-spacing: 0; | ||
line-height: 30.8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Shamelessly inspired by https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#differentiate_between_similar_errors | ||
export class NCIError extends Error { | ||
constructor(message = '') { | ||
super(message); | ||
|
||
// Maintains proper stack trace for where our error was thrown | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
|
||
this.name = this.constructor.name; | ||
this.date = new Date(); | ||
} | ||
} | ||
export class NotFoundError extends NCIError { | ||
constructor(message = 'Resource not found') { | ||
super(message); | ||
} | ||
} | ||
|
||
export class InvalidCriteriaError extends NCIError { | ||
constructor(errors = [], message = 'Invalid criteria') { | ||
super(message); | ||
this.errors = errors; | ||
} | ||
} | ||
|
||
export class GenericError extends NCIError { | ||
constructor(message = 'An error occurred') { | ||
super(message); | ||
} | ||
} | ||
|
||
export class ApiError extends NCIError { | ||
constructor(message = 'API error', statusCode = 500) { | ||
super(message); | ||
this.statusCode = statusCode; | ||
} | ||
} | ||
|
||
export class ApiServerError extends NCIError { | ||
constructor(message = 'API server error', statusCode = 500) { | ||
super(message); | ||
this.statusCode = statusCode; | ||
} | ||
} |
Oops, something went wrong.