1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

[api-minor] Remove the image-related error message prefixes

Other custom errors, based on `BaseException`, do not use such a format.
This commit is contained in:
Jonas Jenwald 2024-04-20 12:48:33 +02:00
parent 5ad42c13ad
commit 912b57b95d
8 changed files with 33 additions and 15 deletions

View file

@ -1,4 +1,5 @@
import {
Jbig2Error,
Jbig2Image,
setVerbosityLevel,
VerbosityLevel,
@ -7,9 +8,12 @@ import {
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
setVerbosityLevel(VerbosityLevel.ERRORS);
const ignored = ["Cannot read properties", "JBIG2 error"];
const ignored = ["Cannot read properties"];
function ignoredError(error) {
if (error instanceof Jbig2Error) {
return true;
}
return ignored.some(message => error.message.includes(message));
}

View file

@ -1,4 +1,5 @@
import {
JpegError,
JpegImage,
setVerbosityLevel,
VerbosityLevel,
@ -7,9 +8,12 @@ import {
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
setVerbosityLevel(VerbosityLevel.ERRORS);
const ignored = ["Cannot read properties", "JPEG error"];
const ignored = ["Cannot read properties"];
function ignoredError(error) {
if (error instanceof JpegError) {
return true;
}
return ignored.some(message => error.message.includes(message));
}

View file

@ -1,4 +1,5 @@
import {
JpxError,
JpxImage,
setVerbosityLevel,
VerbosityLevel,
@ -7,9 +8,12 @@ import {
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
setVerbosityLevel(VerbosityLevel.ERRORS);
const ignored = ["Cannot read properties", "JPX error"];
const ignored = ["Cannot read properties"];
function ignoredError(error) {
if (error instanceof JpxError) {
return true;
}
return ignored.some(message => error.message.includes(message));
}

View file

@ -18,9 +18,9 @@ import {
setVerbosityLevel,
VerbosityLevel,
} from "../../src/shared/util.js";
import { Jbig2Image } from "../../src/core/jbig2.js";
import { JpegImage } from "../../src/core/jpg.js";
import { JpxImage } from "../../src/core/jpx.js";
import { Jbig2Error, Jbig2Image } from "../../src/core/jbig2.js";
import { JpegError, JpegImage } from "../../src/core/jpg.js";
import { JpxError, JpxImage } from "../../src/core/jpx.js";
describe("pdfimage_api", function () {
it("checks that the *official* PDF.js-image decoders API exposes the expected functionality", async function () {
@ -35,8 +35,11 @@ describe("pdfimage_api", function () {
// hence we copy the data to allow using a simple comparison below.
expect({ ...pdfimageAPI }).toEqual({
getVerbosityLevel,
Jbig2Error,
Jbig2Image,
JpegError,
JpegImage,
JpxError,
JpxImage,
setVerbosityLevel,
VerbosityLevel,