fix: explicit service connection error

This commit is contained in:
Alexander Krasnorutskiy 2020-11-30 13:42:31 -08:00
Родитель c52c64065d
Коммит 3a2f60d542
3 изменённых файлов: 22 добавлений и 22 удалений

Просмотреть файл

@ -65,15 +65,15 @@ export const english: IAppStrings = {
title: "Use prebuilt model to get data",
description: "Start with a pre-built model to extract data from your forms – Invoices, Receipts, Business cards and more. Submit your data and get results right away."
},
layoutPredict:{
title:"Use Layout to get text, tables and selection marks",
description:"Try out the Form Recognizer Layout service to extract text, tables, selection marks and the structure of your document."
layoutPredict: {
title: "Use Layout to get text, tables and selection marks",
description: "Try out the Form Recognizer Layout service to extract text, tables, selection marks and the structure of your document."
},
trainWithLabels:{
title:"Use Custom to train a model with labels and get key value pairs",
description:"You provide your own training data and do the learning. The model you create can train to your industry-specific forms."
trainWithLabels: {
title: "Use Custom to train a model with labels and get key value pairs",
description: "You provide your own training data and do the learning. The model you create can train to your industry-specific forms."
},
quickStartGuide:"Quick start guide",
quickStartGuide: "Quick start guide",
},
appSettings: {
title: "Application Settings",
@ -245,7 +245,7 @@ export const english: IAppStrings = {
inProgress: "Analysis in progress...",
anlayWithPrebuiltModels: "Analyze ${name} (preview)",
},
layoutPredict:{
layoutPredict: {
title: "Layout analyze",
inProgress: "Analysis in progress...",
},
@ -298,19 +298,19 @@ export const english: IAppStrings = {
notCompatibleTagType: "Tag type is not compatible with this feature. If you want to change type of this tag, please remove or reassign all labels which using this tag in your project.",
checkboxPerTagLimit: "Cannot assign more than one checkbox per tag",
notCompatibleWithDrawnRegionTag: "Drawn regions and ${otherCatagory} values cannot both be assigned to the same document's tag",
replaceAllExitingLabels:"Are you sure you want to replace selected tag's labels?",
replaceAllExitingLabelsTitle:"Replace tag's labels",
replaceAllExitingLabels: "Are you sure you want to replace selected tag's labels?",
replaceAllExitingLabelsTitle: "Replace tag's labels",
},
preText:{
autoLabel:"Auto-labeled: ",
revised:"Revised: ",
preText: {
autoLabel: "Auto-labeled: ",
revised: "Revised: ",
},
toolbar: {
add: "Add new tag",
onlyShowCurrentPageTags: "Only show tags used in current page",
showAllTags: "Show all tags",
showOriginLabels:"Show origin labels",
hideOriginLabels:"Hide origin labels",
showOriginLabels: "Show origin labels",
hideOriginLabels: "Hide origin labels",
contextualMenu: "Contextual Menu",
delete: "Delete tag",
edit: "Edit tag",
@ -708,7 +708,7 @@ export const english: IAppStrings = {
},
endpointConnectionError: {
title: "Error connecting to endpoint",
message: "Cannot connect to ${endpoint}. Please make sure the network connection is good and specified endpoint is correct.",
message: "Cannot connect to ${endpoint} - \"${apiUriBase}\". Please make sure the network connection is good and specified endpoint is correct.",
},
tooManyRequests: {
title: "Too many requests",

Просмотреть файл

@ -417,7 +417,7 @@ export default class TrainPage extends React.Component<ITrainPageProps, ITrainPa
this.setState({ modelUrl: result.headers.location });
return result;
} catch (err) {
ServiceHelper.handleServiceError({...err, endpoint: baseURL});
ServiceHelper.handleServiceError({...err, endpoint: baseURL, apiUriBase: this.props.project.apiUriBase});
}
}
private async cleanLabelData() {
@ -611,7 +611,7 @@ export default class TrainPage extends React.Component<ITrainPageProps, ITrainPa
project.apiKey as string,
).then(res => res.request.response);
} catch (error) {
ServiceHelper.handleServiceError({...error, endpoint: baseURL});
ServiceHelper.handleServiceError({...error, endpoint: baseURL, apiUriBase: project.apiUriBase});
}
}
}

Просмотреть файл

@ -17,7 +17,7 @@ export default class ServiceHelper {
} else if (err.response?.status === 404) {
throw new AppError(
ErrorCode.HttpStatusNotFound,
"Please make sure the service endpoint is correct.",
`Please make sure the service endpoint - "${err.apiUriBase}" is correct.`,
"Endpoint not found");
} else if (err.response.status === 429) {
const response = err.response;
@ -49,17 +49,17 @@ export default class ServiceHelper {
"Error");
}
} else if (err.endpoint) {
toast.warn(interpolate(strings.errors.endpointConnectionError.message, {endpoint: "form recognizer backend URL"}), {autoClose: 10000})
toast.warn(interpolate(strings.errors.endpointConnectionError.message, {endpoint: "form recognizer backend URL", apiUriBase: err.apiUriBase}), {autoClose: 10000})
throw new AppError(
ErrorCode.HttpStatusNotFound,
interpolate(strings.errors.endpointConnectionError.message, {endpoint: "form recognizer backend URL"}),
interpolate(strings.errors.endpointConnectionError.message, {endpoint: "form recognizer backend URL", apiUriBase: err.apiUriBase}),
strings.errors.endpointConnectionError.title);
} else {
// Network Error
toast.warn("Over rate limitation, please try again later",{autoClose: 10000})
throw new AppError(
ErrorCode.HttpStatusNotFound,
"Cannot resolve the host name. Please make sure the service endpoint is correct.",
"Cannot resolve the host name. Please make sure the service endpoint - is correct.",
"Endpoint not found");
}
}