[Gekidou MM-45178] Improve wording about url not being a valid one (#6449)
* if the API client returns and error, throw a new error with better descriptive text for the user * add intl to message * move happy path code into try block
This commit is contained in:
parent
a0e1f2dbd6
commit
4dfb9fb60c
2 changed files with 16 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ import UserAgent from 'react-native-user-agent';
|
|||
import LocalConfig from '@assets/config.json';
|
||||
import {Client} from '@client/rest';
|
||||
import * as ClientConstants from '@client/rest/constants';
|
||||
import ClientError from '@client/rest/error';
|
||||
import {CERTIFICATE_ERRORS} from '@constants/network';
|
||||
import ManagedApp from '@init/managed_app';
|
||||
import {logError} from '@utils/log';
|
||||
|
|
@ -77,9 +78,20 @@ class NetworkManager {
|
|||
|
||||
public createClient = async (serverUrl: string, bearerToken?: string) => {
|
||||
const config = await this.buildConfig();
|
||||
const {client} = await getOrCreateAPIClient(serverUrl, config, this.clientErrorEventHandler);
|
||||
const csrfToken = await getCSRFFromCookie(serverUrl);
|
||||
this.clients[serverUrl] = new Client(client, serverUrl, bearerToken, csrfToken);
|
||||
try {
|
||||
const {client} = await getOrCreateAPIClient(serverUrl, config, this.clientErrorEventHandler);
|
||||
const csrfToken = await getCSRFFromCookie(serverUrl);
|
||||
this.clients[serverUrl] = new Client(client, serverUrl, bearerToken, csrfToken);
|
||||
} catch (error) {
|
||||
throw new ClientError(serverUrl, {
|
||||
message: 'Can’t find this server. Check spelling and URL format.',
|
||||
intl: {
|
||||
id: 'apps.error.network.no_server',
|
||||
defaultMessage: 'Can’t find this server. Check spelling and URL format.',
|
||||
},
|
||||
url: serverUrl,
|
||||
});
|
||||
}
|
||||
|
||||
return this.clients[serverUrl];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
"apps.error.form.submit.pretext": "There has been an error submitting the modal. Contact the app developer. Details: {details}",
|
||||
"apps.error.lookup.error_preparing_request": "Error preparing lookup request: {errorMessage}",
|
||||
"apps.error.malformed_binding": "This binding is not properly formed. Contact the App developer.",
|
||||
"apps.error.network.no_server": "Can’t find this server. Check spelling and URL format.",
|
||||
"apps.error.parser": "Parsing error: {error}",
|
||||
"apps.error.parser.empty_value": "Empty values are not allowed.",
|
||||
"apps.error.parser.execute_non_leaf": "You must select a subcommand.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue