mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Reporting] Refactor error messages with human-friendly version of message (#136501)
* refactor error code messages with new method specifically for human-friendly version of errors * update error copy Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
d16a4d8bd9
commit
af3a3cba9a
2 changed files with 19 additions and 29 deletions
|
@ -8,6 +8,12 @@
|
|||
/* eslint-disable max-classes-per-file */
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export interface ReportingError {
|
||||
/**
|
||||
* Return a message describing the error that is human friendly
|
||||
*/
|
||||
humanFriendlyMessage?(): string;
|
||||
}
|
||||
export abstract class ReportingError extends Error {
|
||||
/**
|
||||
* A string that uniquely brands an error type. This is used to power telemetry
|
||||
|
@ -87,17 +93,10 @@ export class PdfWorkerOutOfMemoryError extends ReportingError {
|
|||
return PdfWorkerOutOfMemoryError.code;
|
||||
}
|
||||
|
||||
details = i18n.translate('xpack.reporting.common.pdfWorkerOutOfMemoryErrorMessage', {
|
||||
defaultMessage:
|
||||
'Cannot generate PDF due to low memory. Consider making a smaller PDF before retrying this report.',
|
||||
});
|
||||
|
||||
/**
|
||||
* No need to provide extra details, we know exactly what happened and can provide
|
||||
* a nicely formatted message
|
||||
*/
|
||||
public override get message(): string {
|
||||
return this.details;
|
||||
public humanFriendlyMessage() {
|
||||
return i18n.translate('xpack.reporting.common.pdfWorkerOutOfMemoryErrorMessage', {
|
||||
defaultMessage: `Can't generate a PDF due to insufficient memory. Try making a smaller PDF and retrying this report.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,16 +106,10 @@ export class BrowserCouldNotLaunchError extends ReportingError {
|
|||
return BrowserCouldNotLaunchError.code;
|
||||
}
|
||||
|
||||
details = i18n.translate('xpack.reporting.common.browserCouldNotLaunchErrorMessage', {
|
||||
defaultMessage: 'Cannot generate screenshots because the browser did not launch.',
|
||||
});
|
||||
|
||||
/**
|
||||
* For this error message we expect that users will use the diagnostics
|
||||
* functionality in reporting to debug further.
|
||||
*/
|
||||
public override get message() {
|
||||
return this.details;
|
||||
public humanFriendlyMessage() {
|
||||
return i18n.translate('xpack.reporting.common.browserCouldNotLaunchErrorMessage', {
|
||||
defaultMessage: `Can't generate screenshots because the browser did not launch. See the server logs for more information.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,12 +144,9 @@ export class VisualReportingSoftDisabledError extends ReportingError {
|
|||
return VisualReportingSoftDisabledError.code;
|
||||
}
|
||||
|
||||
details = i18n.translate('xpack.reporting.common.cloud.insufficientSystemMemoryError', {
|
||||
defaultMessage:
|
||||
'This report cannot be generated because Kibana does not have sufficient memory.',
|
||||
});
|
||||
|
||||
public override get message() {
|
||||
return this.details;
|
||||
humanFriendlyMessage() {
|
||||
return i18n.translate('xpack.reporting.common.cloud.insufficientSystemMemoryError', {
|
||||
defaultMessage: `Can't generate this report due to insufficient memory.`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ export class ExecuteReportTask implements ReportingTask {
|
|||
docOutput.error_code = output.error_code;
|
||||
} else {
|
||||
const defaultOutput = null;
|
||||
docOutput.content = output.toString() || defaultOutput;
|
||||
docOutput.content = output.humanFriendlyMessage?.() || output.toString() || defaultOutput;
|
||||
docOutput.content_type = unknownMime;
|
||||
docOutput.warnings = [output.toString()];
|
||||
docOutput.error_code = output.code;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue