mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-07 17:05:38 +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:
parent
5ad42c13ad
commit
912b57b95d
8 changed files with 33 additions and 15 deletions
|
@ -20,7 +20,7 @@ import { CCITTFaxDecoder } from "./ccitt.js";
|
||||||
|
|
||||||
class Jbig2Error extends BaseException {
|
class Jbig2Error extends BaseException {
|
||||||
constructor(msg) {
|
constructor(msg) {
|
||||||
super(`JBIG2 error: ${msg}`, "Jbig2Error");
|
super(msg, "Jbig2Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2593,4 +2593,4 @@ class Jbig2Image {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Jbig2Image };
|
export { Jbig2Error, Jbig2Image };
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { readUint16 } from "./core_utils.js";
|
||||||
|
|
||||||
class JpegError extends BaseException {
|
class JpegError extends BaseException {
|
||||||
constructor(msg) {
|
constructor(msg) {
|
||||||
super(`JPEG error: ${msg}`, "JpegError");
|
super(msg, "JpegError");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1580,4 +1580,4 @@ class JpegImage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { JpegImage };
|
export { JpegError, JpegImage };
|
||||||
|
|
|
@ -18,7 +18,7 @@ import OpenJPEG from "../../external/openjpeg/openjpeg.js";
|
||||||
|
|
||||||
class JpxError extends BaseException {
|
class JpxError extends BaseException {
|
||||||
constructor(msg) {
|
constructor(msg) {
|
||||||
super(`JPX error: ${msg}`, "JpxError");
|
super(msg, "JpxError");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,4 +68,4 @@ class JpxImage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { JpxImage };
|
export { JpxError, JpxImage };
|
||||||
|
|
|
@ -18,9 +18,9 @@ import {
|
||||||
setVerbosityLevel,
|
setVerbosityLevel,
|
||||||
VerbosityLevel,
|
VerbosityLevel,
|
||||||
} from "./shared/util.js";
|
} from "./shared/util.js";
|
||||||
import { Jbig2Image } from "./core/jbig2.js";
|
import { Jbig2Error, Jbig2Image } from "./core/jbig2.js";
|
||||||
import { JpegImage } from "./core/jpg.js";
|
import { JpegError, JpegImage } from "./core/jpg.js";
|
||||||
import { JpxImage } from "./core/jpx.js";
|
import { JpxError, JpxImage } from "./core/jpx.js";
|
||||||
|
|
||||||
/* eslint-disable-next-line no-unused-vars */
|
/* eslint-disable-next-line no-unused-vars */
|
||||||
const pdfjsVersion =
|
const pdfjsVersion =
|
||||||
|
@ -31,8 +31,11 @@ const pdfjsBuild =
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getVerbosityLevel,
|
getVerbosityLevel,
|
||||||
|
Jbig2Error,
|
||||||
Jbig2Image,
|
Jbig2Image,
|
||||||
|
JpegError,
|
||||||
JpegImage,
|
JpegImage,
|
||||||
|
JpxError,
|
||||||
JpxImage,
|
JpxImage,
|
||||||
setVerbosityLevel,
|
setVerbosityLevel,
|
||||||
VerbosityLevel,
|
VerbosityLevel,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
Jbig2Error,
|
||||||
Jbig2Image,
|
Jbig2Image,
|
||||||
setVerbosityLevel,
|
setVerbosityLevel,
|
||||||
VerbosityLevel,
|
VerbosityLevel,
|
||||||
|
@ -7,9 +8,12 @@ import {
|
||||||
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
|
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
|
||||||
setVerbosityLevel(VerbosityLevel.ERRORS);
|
setVerbosityLevel(VerbosityLevel.ERRORS);
|
||||||
|
|
||||||
const ignored = ["Cannot read properties", "JBIG2 error"];
|
const ignored = ["Cannot read properties"];
|
||||||
|
|
||||||
function ignoredError(error) {
|
function ignoredError(error) {
|
||||||
|
if (error instanceof Jbig2Error) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return ignored.some(message => error.message.includes(message));
|
return ignored.some(message => error.message.includes(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
JpegError,
|
||||||
JpegImage,
|
JpegImage,
|
||||||
setVerbosityLevel,
|
setVerbosityLevel,
|
||||||
VerbosityLevel,
|
VerbosityLevel,
|
||||||
|
@ -7,9 +8,12 @@ import {
|
||||||
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
|
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
|
||||||
setVerbosityLevel(VerbosityLevel.ERRORS);
|
setVerbosityLevel(VerbosityLevel.ERRORS);
|
||||||
|
|
||||||
const ignored = ["Cannot read properties", "JPEG error"];
|
const ignored = ["Cannot read properties"];
|
||||||
|
|
||||||
function ignoredError(error) {
|
function ignoredError(error) {
|
||||||
|
if (error instanceof JpegError) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return ignored.some(message => error.message.includes(message));
|
return ignored.some(message => error.message.includes(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
JpxError,
|
||||||
JpxImage,
|
JpxImage,
|
||||||
setVerbosityLevel,
|
setVerbosityLevel,
|
||||||
VerbosityLevel,
|
VerbosityLevel,
|
||||||
|
@ -7,9 +8,12 @@ import {
|
||||||
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
|
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
|
||||||
setVerbosityLevel(VerbosityLevel.ERRORS);
|
setVerbosityLevel(VerbosityLevel.ERRORS);
|
||||||
|
|
||||||
const ignored = ["Cannot read properties", "JPX error"];
|
const ignored = ["Cannot read properties"];
|
||||||
|
|
||||||
function ignoredError(error) {
|
function ignoredError(error) {
|
||||||
|
if (error instanceof JpxError) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return ignored.some(message => error.message.includes(message));
|
return ignored.some(message => error.message.includes(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ import {
|
||||||
setVerbosityLevel,
|
setVerbosityLevel,
|
||||||
VerbosityLevel,
|
VerbosityLevel,
|
||||||
} from "../../src/shared/util.js";
|
} from "../../src/shared/util.js";
|
||||||
import { Jbig2Image } from "../../src/core/jbig2.js";
|
import { Jbig2Error, Jbig2Image } from "../../src/core/jbig2.js";
|
||||||
import { JpegImage } from "../../src/core/jpg.js";
|
import { JpegError, JpegImage } from "../../src/core/jpg.js";
|
||||||
import { JpxImage } from "../../src/core/jpx.js";
|
import { JpxError, JpxImage } from "../../src/core/jpx.js";
|
||||||
|
|
||||||
describe("pdfimage_api", function () {
|
describe("pdfimage_api", function () {
|
||||||
it("checks that the *official* PDF.js-image decoders API exposes the expected functionality", async 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.
|
// hence we copy the data to allow using a simple comparison below.
|
||||||
expect({ ...pdfimageAPI }).toEqual({
|
expect({ ...pdfimageAPI }).toEqual({
|
||||||
getVerbosityLevel,
|
getVerbosityLevel,
|
||||||
|
Jbig2Error,
|
||||||
Jbig2Image,
|
Jbig2Image,
|
||||||
|
JpegError,
|
||||||
JpegImage,
|
JpegImage,
|
||||||
|
JpxError,
|
||||||
JpxImage,
|
JpxImage,
|
||||||
setVerbosityLevel,
|
setVerbosityLevel,
|
||||||
VerbosityLevel,
|
VerbosityLevel,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue