Fix exception type in build()