Skip to content

Commit 9f61d2c

Browse files
committed
Ensure the wrapper error messages are similar to libsolc
1 parent 656a40e commit 9f61d2c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

test/compiler.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,21 +563,21 @@ function runTests (solc, versionText) {
563563
t.test('compiling standard JSON (invalid JSON)', function (st) {
564564
var output = JSON.parse(solc.compile('{invalid'));
565565
// TODO: change wrapper to output matching error
566-
st.ok(expectError(output, 'JSONError', 'Line 1, Column 2\n Missing \'}\' or object member name') || expectError(output, 'SOLCError', 'Invalid JSON supplied'));
566+
st.ok(expectError(output, 'JSONError', 'Line 1, Column 2\n Missing \'}\' or object member name') || expectError(output, 'SOLCError', 'Invalid JSON supplied:'));
567567
st.end();
568568
});
569569

570570
t.test('compiling standard JSON (invalid language)', function (st) {
571571
var output = JSON.parse(solc.compile('{"language":"InvalidSolidity","sources":{"cont.sol":{"content":""}}}'));
572572
// TODO: change wrapper to output matching error
573-
st.ok(expectError(output, 'JSONError', 'supported as a language.') || expectError(output, 'SOLCError', 'Only Solidity sources are supported'));
573+
st.ok(expectError(output, 'JSONError', 'supported as a language.') || expectError(output, 'SOLCError', 'Only "Solidity" is supported as a language.'));
574574
st.end();
575575
});
576576

577577
t.test('compiling standard JSON (no sources)', function (st) {
578578
var output = JSON.parse(solc.compile('{"language":"Solidity"}'));
579579
// TODO: change wrapper to output matching error
580-
st.ok(expectError(output, 'JSONError', 'No input sources specified.') || expectError(output, 'SOLCError', 'No input specified'));
580+
st.ok(expectError(output, 'JSONError', 'No input sources specified.') || expectError(output, 'SOLCError', 'No input sources specified.'));
581581
st.end();
582582
});
583583

@@ -586,7 +586,7 @@ function runTests (solc, versionText) {
586586
if (solc.features.multipleInputs) {
587587
st.ok(expectNoError(output));
588588
} else {
589-
st.ok(expectError(output, 'SOLCError', 'Multiple sources provided, but compiler only supports single input') || expectError(output, 'Parser error', 'Parser error: Source not found.'));
589+
st.ok(expectError(output, 'SOLCError', 'Multiple sources provided, but compiler only supports single input.') || expectError(output, 'Parser error', 'Parser error: Source not found.'));
590590
}
591591
st.end();
592592
});

wrapper.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ function setupMethods (soljson) {
148148
}
149149

150150
if (input['language'] !== 'Solidity') {
151-
return formatFatalError('Only Solidity sources are supported');
151+
return formatFatalError('Only "Solidity" is supported as a language.');
152152
}
153153

154154
// NOTE: this is deliberately `== null`
155155
if (input['sources'] == null || input['sources'].length === 0) {
156-
return formatFatalError('No input specified');
156+
return formatFatalError('No input sources specified.');
157157
}
158158

159159
// Bail out early
160160
if ((input['sources'].length > 1) && (compileJSONMulti === null)) {
161-
return formatFatalError('Multiple sources provided, but compiler only supports single input');
161+
return formatFatalError('Multiple sources provided, but compiler only supports single input.');
162162
}
163163

164164
function isOptimizerEnabled (input) {
@@ -192,14 +192,14 @@ function setupMethods (soljson) {
192192
}
193193
output = translate.translateJsonCompilerOutput(output, libraries);
194194
if (output == null) {
195-
return formatFatalError('Failed to process output');
195+
return formatFatalError('Failed to process output.');
196196
}
197197
return JSON.stringify(output);
198198
}
199199

200200
var sources = translateSources(input);
201201
if (sources === null || Object.keys(sources).length === 0) {
202-
return formatFatalError('Failed to process sources');
202+
return formatFatalError('Failed to process sources.');
203203
}
204204

205205
// Try linking if libraries were supplied

0 commit comments

Comments
 (0)