Skip to content

Commit aaa520d

Browse files
authored
Merge pull request #1438 from olafurpg/fix-1437/dotc-error-handling
Fix #1437: handle build failure in bin/dotc.
2 parents a7fab6d + b2186e3 commit aaa520d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

bin/common

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,26 @@ function find_jar {
3434
echo "$artifact"
3535
}
3636

37+
# Log used to communicate errors from a command substitution, for example:
38+
# $(sbt package || (echo msg >> $ERROR_LOG; kill -SIGTERM $$))
39+
ERROR_LOG=error.log
40+
trap onTerminate SIGTERM
41+
42+
onTerminate() {
43+
if [ -f $ERROR_LOG ]; then
44+
cat $ERROR_LOG
45+
rm -f $ERROR_LOG
46+
fi
47+
exit 1 # $? is lost from subprocess in command substitution.
48+
}
49+
3750
function build_jar {
3851
# Usage:
3952
# build_jar package path/to/jar/dir ['/some/sed/command']
4053
#
4154
# Last arg is optional
4255
cd $DOTTY_ROOT >& /dev/null
43-
local build_output=$(sbt "$1")
56+
local build_output=$(sbt "$1" || (echo "failed to run: sbt $1" >> $ERROR_LOG; kill -SIGTERM $$))
4457
local jar=$(echo $build_output | sed -n 's/.*Packaging //g; s/ \.\.\..*//g; /^\/.*/p')
4558

4659
local sedjar="$3"

0 commit comments

Comments
 (0)