add checking for error states
Merge pull request #2565 from WalterBright/traits-compile

add checking for error states