Use Formula#system and existing error handling in scons helper

Fixes #27553.