MOBILE-4059 login: Add error details for support
parent
1a7d64a0d4
commit
238dc458fc
|
@ -22,6 +22,7 @@ import { CoreUserSupport } from '@features/user/services/support';
|
||||||
export class CoreSiteError extends CoreError {
|
export class CoreSiteError extends CoreError {
|
||||||
|
|
||||||
errorcode?: string;
|
errorcode?: string;
|
||||||
|
errorDetails?: string;
|
||||||
critical?: boolean;
|
critical?: boolean;
|
||||||
loggedOut?: boolean;
|
loggedOut?: boolean;
|
||||||
contactSupport?: boolean;
|
contactSupport?: boolean;
|
||||||
|
@ -31,6 +32,7 @@ export class CoreSiteError extends CoreError {
|
||||||
super(options.message);
|
super(options.message);
|
||||||
|
|
||||||
this.errorcode = options.errorcode;
|
this.errorcode = options.errorcode;
|
||||||
|
this.errorDetails = options.errorDetails;
|
||||||
this.critical = options.critical;
|
this.critical = options.critical;
|
||||||
this.loggedOut = options.loggedOut;
|
this.loggedOut = options.loggedOut;
|
||||||
this.contactSupport = options.contactSupport;
|
this.contactSupport = options.contactSupport;
|
||||||
|
@ -68,6 +70,7 @@ export class CoreSiteError extends CoreError {
|
||||||
export type CoreSiteErrorOptions = {
|
export type CoreSiteErrorOptions = {
|
||||||
message: string;
|
message: string;
|
||||||
errorcode?: string;
|
errorcode?: string;
|
||||||
|
errorDetails?: string;
|
||||||
critical?: boolean; // Whether the error is important enough to abort the operation.
|
critical?: boolean; // Whether the error is important enough to abort the operation.
|
||||||
loggedOut?: boolean; // Whether site has been marked as logged out.
|
loggedOut?: boolean; // Whether site has been marked as logged out.
|
||||||
contactSupport?: boolean;
|
contactSupport?: boolean;
|
||||||
|
|
|
@ -386,10 +386,14 @@ export class CoreLoginSitePage implements OnInit {
|
||||||
let errorMessage = CoreDomUtils.getErrorMessage(error);
|
let errorMessage = CoreDomUtils.getErrorMessage(error);
|
||||||
let siteExists = false;
|
let siteExists = false;
|
||||||
let supportPageUrl: string | null = null;
|
let supportPageUrl: string | null = null;
|
||||||
|
let errorDetails: string | undefined;
|
||||||
|
let errorCode: string | undefined;
|
||||||
|
|
||||||
if (error instanceof CoreSiteError) {
|
if (error instanceof CoreSiteError) {
|
||||||
siteExists = !!error.siteConfig;
|
siteExists = !!error.siteConfig;
|
||||||
supportPageUrl = error.canContactSupport() ? error.getSupportPageUrl() : null;
|
supportPageUrl = error.canContactSupport() ? error.getSupportPageUrl() : null;
|
||||||
|
errorDetails = error.errorDetails;
|
||||||
|
errorCode = error.errorcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errorMessage == Translate.instant('core.cannotconnecttrouble')) {
|
if (errorMessage == Translate.instant('core.cannotconnecttrouble')) {
|
||||||
|
@ -413,6 +417,7 @@ export class CoreLoginSitePage implements OnInit {
|
||||||
handler: () => CoreUserSupport.contact({
|
handler: () => CoreUserSupport.contact({
|
||||||
supportPageUrl,
|
supportPageUrl,
|
||||||
subject: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }),
|
subject: Translate.instant('core.cannotconnect', { $a: CoreSite.MINIMUM_MOODLE_VERSION }),
|
||||||
|
message: `Error: ${errorCode}\n\n${errorDetails}`,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
|
|
|
@ -296,19 +296,17 @@ export class CoreSitesProvider {
|
||||||
|
|
||||||
// Check that the user can authenticate.
|
// Check that the user can authenticate.
|
||||||
if (!config.enablewebservices) {
|
if (!config.enablewebservices) {
|
||||||
throw new CoreSiteError({
|
throw this.createCannotConnectError(
|
||||||
message: Translate.instant('core.login.webservicesnotenabled'),
|
'webservicesnotenabled',
|
||||||
critical: true,
|
Translate.instant('core.login.webservicesnotenabled'),
|
||||||
contactSupport: true,
|
config,
|
||||||
siteConfig: config,
|
);
|
||||||
});
|
|
||||||
} else if (!config.enablemobilewebservice) {
|
} else if (!config.enablemobilewebservice) {
|
||||||
throw new CoreSiteError({
|
throw this.createCannotConnectError(
|
||||||
message: Translate.instant('core.login.mobileservicesnotenabled'),
|
'mobileservicesnotenabled',
|
||||||
critical: true,
|
Translate.instant('core.login.mobileservicesnotenabled'),
|
||||||
contactSupport: true,
|
config,
|
||||||
siteConfig: config,
|
);
|
||||||
});
|
|
||||||
} else if (config.maintenanceenabled) {
|
} else if (config.maintenanceenabled) {
|
||||||
let message = Translate.instant('core.sitemaintenance');
|
let message = Translate.instant('core.sitemaintenance');
|
||||||
if (config.maintenancemessage) {
|
if (config.maintenancemessage) {
|
||||||
|
@ -326,6 +324,29 @@ export class CoreSitesProvider {
|
||||||
return { siteUrl, code: config?.typeoflogin || 0, service: CoreConstants.CONFIG.wsservice, config };
|
return { siteUrl, code: config?.typeoflogin || 0, service: CoreConstants.CONFIG.wsservice, config };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an error to be thrown when it isn't possible to connect to a site.
|
||||||
|
*
|
||||||
|
* @param errorcode Error code.
|
||||||
|
* @param errorDetails Error details.
|
||||||
|
* @param siteConfig Site config.
|
||||||
|
* @return Cannot connect error.
|
||||||
|
*/
|
||||||
|
protected createCannotConnectError(
|
||||||
|
errorcode: string,
|
||||||
|
errorDetails: string,
|
||||||
|
siteConfig: CoreSitePublicConfigResponse,
|
||||||
|
): CoreSiteError {
|
||||||
|
return new CoreSiteError({
|
||||||
|
errorcode,
|
||||||
|
errorDetails,
|
||||||
|
siteConfig,
|
||||||
|
message: Translate.instant('core.cannotconnecttrouble'),
|
||||||
|
critical: true,
|
||||||
|
contactSupport: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Treat an error returned by getPublicConfig in checkSiteWithProtocol. Converts the error to a CoreSiteError.
|
* Treat an error returned by getPublicConfig in checkSiteWithProtocol. Converts the error to a CoreSiteError.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue