File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,11 @@ function setupMethods (soljson) {
116
116
return formatFatalError ( 'Invalid import callback supplied' ) ;
117
117
}
118
118
119
- input = JSON . parse ( input ) ;
119
+ try {
120
+ input = JSON . parse ( input ) ;
121
+ } catch ( e ) {
122
+ return formatFatalError ( 'Invalid JSON supplied: ' + e . message ) ;
123
+ }
120
124
121
125
if ( input [ 'language' ] !== 'Solidity' ) {
122
126
return formatFatalError ( 'Only Solidity sources are supported' ) ;
@@ -155,7 +159,12 @@ function setupMethods (soljson) {
155
159
}
156
160
157
161
function translateOutput ( output ) {
158
- output = translate . translateJsonCompilerOutput ( JSON . parse ( output ) ) ;
162
+ try {
163
+ output = JSON . parse ( output ) ;
164
+ } catch ( e ) {
165
+ return formatFatalError ( 'Compiler returned invalid JSON: ' + e . message ) ;
166
+ }
167
+ output = translate . translateJsonCompilerOutput ( output ) ;
159
168
if ( output == null ) {
160
169
return formatFatalError ( 'Failed to process output' ) ;
161
170
}
@@ -180,7 +189,11 @@ function setupMethods (soljson) {
180
189
}
181
190
182
191
// Try our luck with an ancient compiler
183
- return translateOutput ( compileJSON ( sources [ Object . keys ( sources ) [ 0 ] ] , isOptimizerEnabled ( input ) ) , libraries ) ;
192
+ if ( compileJSON !== null ) {
193
+ return translateOutput ( compileJSON ( sources [ Object . keys ( sources ) [ 0 ] ] , isOptimizerEnabled ( input ) ) , libraries ) ;
194
+ }
195
+
196
+ return formatFatalError ( 'Compiler does not support any known interface.' ) ;
184
197
} ;
185
198
186
199
var version ;
You can’t perform that action at this time.
0 commit comments