Most ERR traps for individual bash functions could be omitted by using at the beginning of the script:
set -o errtrace
and declaring for example trap "error_handler" ERR just once.
This is quite a big refactoring task. Applies to Whonix's build script as well as most packages with scripts.