build: Write out to status file which component failed

And while we're here, create a helper function (this should really go
in task.js probably).