Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ON-40638 # capture error where permissions are not correct #673

Merged
merged 3 commits into from
May 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions src/form-elements/FormElementGoogleAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,35 @@ function FormElementGoogleAddress({
input,
},
(predictions, status) => {
if (
status === google.maps.places.PlacesServiceStatus.ZERO_RESULTS
) {
resolve([])
return
}
if (status !== google.maps.places.PlacesServiceStatus.OK) {
reject('Google Places service not available')
return
switch (status) {
case google.maps.places.PlacesServiceStatus.ZERO_RESULTS: {
resolve([])
break
}
case google.maps.places.PlacesServiceStatus.REQUEST_DENIED: {
reject(
'Google Maps API key has not been configured correctly',
mymattcarroll marked this conversation as resolved.
Show resolved Hide resolved
)
break
}
case google.maps.places.PlacesServiceStatus.OK: {
resolve(predictions ?? [])
break
}
default: {
reject(
'An unknown error has occurred. Please contact support if the problem persists.',
)
}
}
resolve(predictions ?? [])
return
},
)
}).catch((e) => {
if (!abortSignal.aborted) {
Sentry.captureException(e)
}
throw new OneBlinkAppsError(
'An unknown error has occurred. Please contact support if the problem persists.',
{ originalError: e },
e instanceof Error ? e.message : e.toString(),
)
mymattcarroll marked this conversation as resolved.
Show resolved Hide resolved
})

Expand Down Expand Up @@ -162,7 +170,9 @@ function FormElementGoogleAddress({
if (isMounted.current) {
setError(
new OneBlinkAppsError(
mymattcarroll marked this conversation as resolved.
Show resolved Hide resolved
'An unknown error has occurred. Please contact support if the problem persists.',
newError instanceof Error
? newError.message
: 'An unknown error has occurred. Please contact support if the problem persists.',
{
originalError: newError as Error,
},
Expand Down Expand Up @@ -224,7 +234,7 @@ function FormElementGoogleAddress({
{error && (
<div role="alert" className="has-margin-top-8">
<div className="has-text-danger ob-error__text cypress-google-address-details-error-message">
{error.toString()}
{error.message}
</div>
</div>
)}
Expand Down