Skip to content
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

Merged
merged 1 commit into from
Jul 7, 2017
Merged

Removes error() #8581

merged 1 commit into from
Jul 7, 2017

Conversation

yurydelendik
Copy link
Contributor

Part of #8506

Copy link
Contributor

@timvandermeij timvandermeij left a 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.

@@ -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 +
Copy link
Contributor

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.

Copy link
Contributor Author

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"

@@ -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 +
Copy link
Contributor

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.

@@ -76,7 +76,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
return ranges;
}
error('not supported cmap: ' + format);
throw new FormatError(`not supported cmap: ${format}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: not supported -> unsupported

error('Invalid image width: ' + this.width + ' or height: ' +
this.height);
throw new FormatError(`Invalid image width: ${this.width} or ` +
`height: ${this.height}`);
Copy link
Contributor

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.

@@ -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 +
Copy link
Contributor

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}`);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@@ -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);
Copy link
Contributor

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.

@@ -140,8 +140,7 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
}
break;
default:
error('illigal figure');
break;
throw new Error('illigal figure');
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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())

@@ -499,6 +481,18 @@ var XRefParseException = (function XRefParseExceptionClosure() {
return XRefParseException;
})();

var FormatError = (function FormatErrorClosure() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var -> let?

@yurydelendik yurydelendik force-pushed the rm-error branch 2 times, most recently from fe9393d to 565a186 Compare June 29, 2017 16:07
@timvandermeij timvandermeij dismissed their stale review June 30, 2017 21:47

The initial comments I had have been resolved.

@timvandermeij
Copy link
Contributor

timvandermeij commented Jun 30, 2017

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.

@Snuffleupagus
Copy link
Collaborator

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Jul 6, 2017

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/8e3d3d0ed96b06a/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 6, 2017

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.215.176.217:8877/64797c8b6fc01c9/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 6, 2017

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/8e3d3d0ed96b06a/output.txt

Total script time: 16.56 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Jul 6, 2017

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/64797c8b6fc01c9/output.txt

Total script time: 29.46 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a 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:

Looks good, thanks for doing this cleanup!

@yurydelendik yurydelendik merged commit 7b4887d into mozilla:master Jul 7, 2017
@yurydelendik yurydelendik deleted the rm-error branch July 7, 2017 14:43
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants