Skip to content

Commit fece367

Browse files
committed
Raise error message if writing a file failed
1 parent 66d9ac6 commit fece367

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

solcjs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,27 @@ if (!output) {
9595
}
9696

9797
fs.ensureDirSync (destination);
98+
99+
function writeFile (file, content) {
100+
file = path.join(destination, file);
101+
fs.writeFile(file, content, function (err) {
102+
if (err) {
103+
console.log('Failed to write ' + file + ': ' + err);
104+
}
105+
});
106+
}
107+
98108
for (var contractName in output.contracts) {
99109
if (argv.bin) {
100-
fs.writeFileSync(path.join(destination, contractName + '.bin'), output.contracts[contractName].bytecode);
110+
writeFile(contractName + '.bin', output.contracts[contractName].bytecode);
101111
}
102112

103113
if (argv.abi) {
104-
fs.writeFileSync(path.join(destination, contractName + '.abi'), output.contracts[contractName].interface);
114+
writeFile(contractName + '.abi', output.contracts[contractName].interface);
105115
}
106116
}
107117

108-
originalUncaughtExceptionListeners.forEach(function (listener) { process.addListener('uncaughtException', listener); });
118+
// Put back original exception handlers.
119+
originalUncaughtExceptionListeners.forEach(function (listener) {
120+
process.addListener('uncaughtException', listener);
121+
});

0 commit comments

Comments
 (0)