Fix build_scan.py error handling, add test

BUG=

Review-Url: https://codereview.chromium.org/2234223002
2 files changed