Bug 1869371 - Strip NS_ERROR_* codes from submitted telemetry r=markh,sync-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D200969
This commit is contained in:
Barret Rennie 2024-02-21 19:33:46 +00:00
Родитель f0e51159ae
Коммит 611413b73c
2 изменённых файлов: 5 добавлений и 1 удалений

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

@ -241,10 +241,14 @@ export class ErrorSanitizer {
NotAllowedError: this.E_PERMISSION_DENIED,
};
// IOUtils error messages include the specific nsresult error code that caused them.
static NS_ERROR_RE = new RegExp(/ \(NS_ERROR_.*\)$/);
static #cleanOSErrorMessage(message, error = undefined) {
if (DOMException.isInstance(error)) {
const sub = this.DOMErrorSubstitutions[error.name];
message = message.replaceAll("\\", "/");
message = message.replace(this.NS_ERROR_RE, "");
if (sub) {
return `${sub} ${message}`;
}

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

@ -734,7 +734,7 @@ add_task(async function test_clean_real_os_error() {
equal(failureReason.name, "unexpectederror");
equal(
failureReason.error,
"OS error [File/Path not found] Could not open the file at [profileDir]/no/such/path.json"
"OS error [File/Path not found] Could not open `[profileDir]/no/such/path.json': file does not exist"
);
});
} finally {