Better management of build failures

Handle build failures and throw a `BuildErrorException`