mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Convert the various ...Exception
s to proper classes, to reduce code duplication
By utilizing a base "class", things become significantly simpler. Unfortunately the new `BaseException` cannot be a proper ES6 class and just extend `Error`, since the SystemJS dependency doesn't seem to play well with that. Note also that we (generally) need to keep the `name` property on the actual `...Exception` object, rather than on its prototype, since the property will otherwise be dropped during the structured cloning used with `postMessage`.
This commit is contained in:
parent
cd909c531f
commit
5d93fda4f2
3 changed files with 44 additions and 120 deletions
|
@ -15,8 +15,8 @@
|
|||
/* eslint no-var: error */
|
||||
|
||||
import {
|
||||
assert, CMapCompressionType, isString, removeNullCharacters, stringToBytes,
|
||||
unreachable, Util, warn
|
||||
assert, BaseException, CMapCompressionType, isString, removeNullCharacters,
|
||||
stringToBytes, unreachable, Util, warn
|
||||
} from '../shared/util';
|
||||
|
||||
const DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
|
||||
|
@ -307,18 +307,12 @@ class PageViewport {
|
|||
}
|
||||
}
|
||||
|
||||
const RenderingCancelledException = (function RenderingCancelledException() {
|
||||
function RenderingCancelledException(msg, type) {
|
||||
this.message = msg;
|
||||
class RenderingCancelledException extends BaseException {
|
||||
constructor(msg, type) {
|
||||
super(msg);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
RenderingCancelledException.prototype = new Error();
|
||||
RenderingCancelledException.prototype.name = 'RenderingCancelledException';
|
||||
RenderingCancelledException.constructor = RenderingCancelledException;
|
||||
|
||||
return RenderingCancelledException;
|
||||
})();
|
||||
}
|
||||
|
||||
const LinkTarget = {
|
||||
NONE: 0, // Default value.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue