11import { Heading , Flex , Text } from "@nypl/design-system-react-components"
2- import type { HTTPStatusCode } from "../../types/appTypes"
2+ import type { APIErrorName , HTTPStatusCode } from "../../types/appTypes"
33import { appConfig } from "../../config/appConfig"
44import { SITE_NAME } from "../../config/constants"
55import RCHead from "../Head/RCHead"
@@ -14,10 +14,15 @@ import Link from "../Link/Link"
1414type ResultsErrorProps = {
1515 page : RCPage
1616 errorStatus : HTTPStatusCode
17+ errorName ?: APIErrorName
1718}
1819
1920/* Display error state that replaces browse/search results. */
20- export default function ResultsError ( { errorStatus, page } : ResultsErrorProps ) {
21+ export default function ResultsError ( {
22+ errorStatus,
23+ errorName,
24+ page,
25+ } : ResultsErrorProps ) {
2126 const { openFeedbackFormWithError } = useContext ( FeedbackContext )
2227 let metadataTitle = "Error"
2328 let errorContent
@@ -28,6 +33,13 @@ export default function ResultsError({ errorStatus, page }: ResultsErrorProps) {
2833 metadataTitle = "Results not found"
2934 errorContent = (
3035 < >
36+ < Image
37+ src = { errorImage }
38+ alt = "Error image"
39+ width = { 96 }
40+ height = { 64 }
41+ style = { { marginBottom : "48px" } }
42+ />
3143 < Heading level = "h3" tabIndex = { - 1 } id = { headingID } mb = "s" >
3244 No results found
3345 </ Heading >
@@ -56,6 +68,13 @@ export default function ResultsError({ errorStatus, page }: ResultsErrorProps) {
5668 case 500 :
5769 errorContent = (
5870 < >
71+ < Image
72+ src = { errorImage }
73+ alt = "Error image"
74+ width = { 96 }
75+ height = { 64 }
76+ style = { { marginBottom : "48px" } }
77+ />
5978 < Heading level = "h3" tabIndex = { - 1 } id = { headingID } mb = "s" >
6079 Something went wrong on our end
6180 </ Heading >
@@ -75,11 +94,58 @@ export default function ResultsError({ errorStatus, page }: ResultsErrorProps) {
7594 </ >
7695 )
7796 break
78-
97+ case 422 :
98+ if ( errorName === "InvalidQuerySyntaxError" ) {
99+ errorContent = (
100+ < >
101+ < Image
102+ src = { errorImage }
103+ alt = "Error image"
104+ width = { 96 }
105+ height = { 64 }
106+ style = { { marginBottom : "48px" } }
107+ />
108+ < Heading level = "h3" tabIndex = { - 1 } id = { headingID } mb = "s" >
109+ Invalid query
110+ </ Heading >
111+ < Text marginBottom = "0" >
112+ Your query contained an invalid search scope or syntax error.
113+ Change your query and try again.
114+ </ Text >
115+ < Text >
116+ { " " }
117+ Read our{ " " }
118+ < Link
119+ isExternal
120+ href = "https://libguides.nypl.org/researchcatalog/query"
121+ >
122+ Query Guide
123+ </ Link > { " " }
124+ to learn how to construct queries or{ " " }
125+ < Link
126+ onClick = { ( ) => openFeedbackFormWithError ( errorStatus ) }
127+ id = "feedback-link"
128+ >
129+ contact us
130+ </ Link > { " " }
131+ for assistance.
132+ </ Text >
133+ </ >
134+ )
135+ break
136+ }
79137 // 4xx
138+ // fallthrough
80139 default :
81140 errorContent = (
82141 < >
142+ < Image
143+ src = { errorImage }
144+ alt = "Error image"
145+ width = { 96 }
146+ height = { 64 }
147+ style = { { marginBottom : "48px" } }
148+ />
83149 < Heading level = "h3" tabIndex = { - 1 } id = { headingID } mb = "s" >
84150 There was an unexpected error
85151 </ Heading >
@@ -115,13 +181,6 @@ export default function ResultsError({ errorStatus, page }: ResultsErrorProps) {
115181 justifyContent = "center"
116182 textAlign = "center"
117183 >
118- < Image
119- src = { errorImage }
120- alt = "Error image"
121- width = { 96 }
122- height = { 64 }
123- style = { { marginBottom : "48px" } }
124- />
125184 { errorContent }
126185 </ Flex >
127186 </ Layout >
0 commit comments