-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removes error() #8581
Removes error() #8581
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this looks good. I really like the idea of specific exception classes.
src/core/colorspace.js
Outdated
@@ -771,8 +772,8 @@ var CalGrayCS = (function CalGrayCSClosure() { | |||
|
|||
// Validate variables as per spec. | |||
if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) { | |||
error('Invalid WhitePoint components for ' + this.name + | |||
', no fallback available'); | |||
throw new FormatError('Invalid WhitePoint components for ' + this.name + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the $(this.name)
syntax here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unable to use that since string must be broken in two line, and lint errors with "Strings must use singlequote"
src/core/colorspace.js
Outdated
@@ -909,8 +911,8 @@ var CalRGBCS = (function CalRGBCSClosure() { | |||
|
|||
// Validate variables as per spec. | |||
if (XW < 0 || ZW < 0 || YW !== 1) { | |||
error('Invalid WhitePoint components for ' + this.name + | |||
', no fallback available'); | |||
throw new FormatError('Invalid WhitePoint components for ' + this.name + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the $(this.name)
syntax here as well.
src/core/font_renderer.js
Outdated
@@ -76,7 +76,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() { | |||
} | |||
return ranges; | |||
} | |||
error('not supported cmap: ' + format); | |||
throw new FormatError(`not supported cmap: ${format}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: not supported -> unsupported
src/core/image.js
Outdated
error('Invalid image width: ' + this.width + ' or height: ' + | ||
this.height); | ||
throw new FormatError(`Invalid image width: ${this.width} or ` + | ||
`height: ${this.height}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alignment is a bit off here.
src/core/image.js
Outdated
@@ -132,8 +135,8 @@ var PDFImage = (function PDFImageClosure() { | |||
colorSpace = Name.get('DeviceCMYK'); | |||
break; | |||
default: | |||
error('JPX images with ' + this.numComps + | |||
' color components not supported.'); | |||
throw new Error('JPX images with ' + this.numComps + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the $(this.numComps)
syntax here as well.
@@ -553,7 +553,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { | |||
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); | |||
} | |||
} else { | |||
error('bad image kind: ' + imgData.kind); | |||
throw new Error(`bad image kind: ${imgData.kind}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a FormatError
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It comes from already parsed data -- FormatError usually thrown as result of PDF parsing.
src/display/pattern_helper.js
Outdated
@@ -415,7 +414,7 @@ var TilingPattern = (function TilingPatternClosure() { | |||
context.strokeStyle = cssColor; | |||
break; | |||
default: | |||
error('Unsupported paint type: ' + paintType); | |||
throw new FormatError('Unsupported paint type: ' + paintType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the $(paintType)
syntax here as well.
src/display/pattern_helper.js
Outdated
@@ -140,8 +140,7 @@ var createMeshCanvas = (function createMeshCanvasClosure() { | |||
} | |||
break; | |||
default: | |||
error('illigal figure'); | |||
break; | |||
throw new Error('illigal figure'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: illigal
-> illegal
// Fatal errors that should trigger the fallback UI and halt execution by | ||
// throwing an exception. | ||
function error(msg) { | ||
if (verbosity >= VERBOSITY_LEVELS.errors) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still use the verbosity anywhere now? If not, we should remove all traces of it as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will keep that for compatibility, also we may add error() back, but without throwing for recording critical stuff (e.g. recovery that we often hide under warn())
src/shared/util.js
Outdated
@@ -499,6 +481,18 @@ var XRefParseException = (function XRefParseExceptionClosure() { | |||
return XRefParseException; | |||
})(); | |||
|
|||
var FormatError = (function FormatErrorClosure() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var
-> let
?
fe9393d
to
565a186
Compare
The initial comments I had have been resolved.
In general this looks good to me. I won't be able to review this entirely in the next two weeks, so if @Snuffleupagus or @brendandahl could do a final review, that would be great so we can land it. |
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/8e3d3d0ed96b06a/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.215.176.217:8877/64797c8b6fc01c9/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/8e3d3d0ed96b06a/output.txt Total script time: 16.56 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/64797c8b6fc01c9/output.txt Total script time: 29.46 mins
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me, with two minor comments:
- The recently added
throw
statement in https://github.com/mozilla/pdf.js/blob/master/src/core/pattern.js#L808 should probably be aFormatError
instead now. - I'm not certain that it's used anywhere, but let's convert
error(...)
in https://github.com/mozilla/pdf.js/blob/master/src/shared/fonts_utils.js too.
Looks good, thanks for doing this cleanup!
Removes error()
Part of #8506