Catch errors from abcde-musicbrainz-tool better
[abcde.git] / abcde
diff --git a/abcde b/abcde
index 8a873fe..a813299 100755 (executable)
--- a/abcde
+++ b/abcde
@@ -504,6 +504,11 @@ makeids ()
                *musicbrainz*)
                        # FIXME: don't assume the first track is 1
                        MBDISCID=$($MUSICBRAINZ --command calcid --discinfo 1 $TRACKS $LEADIN $(($PREGAP + $LEADOUT)) $OFFSETS)
+                       error=$?
+                       if [ $error != 0 ]; then
+                               log error "$MUSICBRAINZ failed to run; ABORT"
+                               exit $error
+                       fi
                        MBTRACKINFO="${MBDISCID} $((TRACKS)) ${COOKEDOFFSETS} $((($LEADOUT + $LEADIN + $IDMAGICNUM) / $CDFRAMES))"
                        ;;
        esac
@@ -2056,6 +2061,11 @@ do_discid ()
                                case $CDDBMETHOD in
                                        *musicbrainz*)
                                                MBTRACKINFO=$($MUSICBRAINZ --command id --device "$CDROM")
+                                               error=$?
+                                               if [ $error != 0 ]; then
+                                                       log error "$MUSICBRAINZ failed to run; ABORT"
+                                                       exit $error
+                                               fi
                                                MBDISCID=$(echo $MBTRACKINFO | cut -d' ' -f1)
                                                ;;
                                esac
@@ -2587,6 +2597,13 @@ do_musicbrainz_read ()
                local SOURCE_WORKDIR="${ABCDETEMPDIR}/data-musicbrainz"
                mkdir -p "${SOURCE_WORKDIR}"
                ${MUSICBRAINZ} --command data --discid "$MBDISCID" --workdir "${SOURCE_WORKDIR}" --start ${NUM_CDDB_MATCHES}
+               # To have got this far, must have been able to run
+               # $MUSICBRAINZ earlier to calculate the ID. Errors here are
+               # non-fatal, maybe a lookup failure? Log and continue.
+               error=$?
+               if [ $error != 0 ]; then
+                       log error "$MUSICBRAINZ failed to run"
+               fi
 
                # Check for no matches.
                # The helper script will write disc matches out to