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

tools: better error message for failed tools/doc/generate #25064

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions tools/doc/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ args.forEach(function(arg) {
} else if (arg.startsWith('--output-directory=')) {
outputDir = arg.replace(/^--output-directory=/, '');
} else if (arg.startsWith('--apilinks=')) {
apilinks = JSON.parse(
fs.readFileSync(arg.replace(/^--apilinks=/, ''), 'utf8')
);
const filename = arg.replace(/^--apilinks=/, '');
try {
apilinks = JSON.parse(
fs.readFileSync(filename, 'utf8')
);
} catch (e) {
console.log(`Failure reading ${filename}, maybe remove it?`);
Copy link
Member

@joyeecheung joyeecheung Dec 16, 2018

Choose a reason for hiding this comment

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

I don't think removing it always solve the issue, depending on how the file is generated the next time (which in turn depends on Makefile deps handling). Usually when I run into this it's because the file is empty (JSON.parse('') errors) because the content is piped from stdout instead of being written by the bogus binary (in which case it would fail properly instead of piping out an empty file silently).

Alternative solution: #25019

throw e;
}
}
});

Expand Down