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

Document 'errors' #61

Closed
wants to merge 4 commits into from
Closed

Document 'errors' #61

wants to merge 4 commits into from

Conversation

chevdor
Copy link
Contributor

@chevdor chevdor commented Oct 23, 2016

No description provided.

Display the content of the error object when the compilation fails
@chevdor chevdor changed the title Issue22 Fix #22 Oct 23, 2016
Copy link
Contributor

@chriseth chriseth 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, I think anything that is not regular output of the compiler should go to stderr. The fact whether the compilation was successful or not should be reported via the process exit status. If there are no errors (but warnings), exit status should report "success" but the stderr stream should be nonempty.

@@ -59,6 +62,7 @@ for (var i = 0; i < files.length; i++) {
}
}

console.log("Compiling with version: " + solc.version());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not clutter stdout

spt.end();
});

t.test('--abi', function (st) {
t.test('--abi -o output', function (st) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert (see comment above).

// only leave the console.error

if (res.errors[0].indexOf('Warning') > 0) {
console.log('Compiled with Warnings: ', res.errors);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please output that on stderr.

@chriseth
Copy link
Contributor

@chevdor could you please provide a summary of the PR as the title (and commit message) instead of just mentioning the issue number?

process.exit(1);
}

if (!files.length)
abort('You must provide at least one file to compile.');
Copy link
Member

Choose a reason for hiding this comment

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

This will need to be wrapper into {} to satisfy the lint.

@@ -11,42 +11,42 @@ tape('CLI', function (t) {

t.test('no parameters', function (st) {
var spt = spawn(st, './solcjs');
spt.stderr.match(/^Must provide a file/);
spt.stderr.match(/^Must provide a file.*/);
Copy link
Member

Choose a reason for hiding this comment

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

The .* shouldn't be needed as there's no closing $ to mean end-of-match.

// https://github.com/ethereum/solc-js/issues/53
// only leave the console.error

if (res.errors[0].indexOf('Warning') > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

I think res.errors[0] is wrong, it should check every single error for being a warning.

Choose a reason for hiding this comment

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

Use Array.prototype.filter.

if (res.errors[0].indexOf('Warning') > 0) {
console.log('Compiled with Warnings: ', res.errors);
} else {
console.error('Compiled with Errors: ', res.errors);

Choose a reason for hiding this comment

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

Use Array.prototype.filter.

@derhuerst
Copy link

@chevdor afaict you don't set the exit code to non-zero.

@chevdor chevdor changed the title Fix #22 Document 'errors' Nov 17, 2016
if (res.errors.filter(function (value) {
value.indexOf('Warning') > 0;
})) {
console.error('Compiled with Warnings: ', res.errors);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrapper is too low-level to be allowed to write to the console.

process.exit(1);
}

if (!files.length) {
abort('You must provide at least one file to compile.');
Copy link
Member

Choose a reason for hiding this comment

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

This has been fixed since.

@@ -41,10 +41,14 @@ var files = argv._;
var destination = argv['output-dir'] || '.'

function abort (msg) {
console.log(msg || 'Error occured');
console.error(msg || 'Error occured');
Copy link
Member

Choose a reason for hiding this comment

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

The error/log change is handled by #129.

@axic
Copy link
Member

axic commented Oct 1, 2017

Closing this as it seems everything has been addressed since.

@axic axic closed this Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants