Skip to content

Instantly share code, notes, and snippets.

@bauefikapa
Created April 28, 2023 16:13
Show Gist options
  • Select an option

  • Save bauefikapa/cb023a460ebe2823a461eebb5dad5e59 to your computer and use it in GitHub Desktop.

Select an option

Save bauefikapa/cb023a460ebe2823a461eebb5dad5e59 to your computer and use it in GitHub Desktop.
const handleResponseErrors = (status: number, errorText: string) => {
if (status === 403 && errorText.toLowerCase().includes("recaptcha")) {
return "There was a verification error, please refresh the page and try asking your question again. If the issue persists please contact support.";
} else if (status === 429 && errorText.includes("User")) {
return "Question limit reached, please wait a few minutes and try again.";
} else if (status === 429 && errorText.includes("Global")) {
return "System capacity reached, please wait a few minutes and try again.";
} else if ([400, 403, 404, 429].includes(status)) {
return "Configuration issue detected, contact support if unresolved shortly.";
} else {
return "There was an unexpected error, please refresh the page and try asking your question again. If the issue persists please contact support.";
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment