The code in meta/classes/image.bbclass do_image_qa indicates that image QA checks should raise oe.utils.ImageQAFailed exceptions when a problem is discovered. When the actual test function is executed by bb.utils.better_exec, there is no special handling for ImageQAFailed and better_exec will print the backtrace before forwarding the exception to do_image_qa to print the expected error messages. It's worth noting that the only image_qa_test in Poky -- license_qa_dead_symlink from meta/classes/license_image.bbclass -- does not use ImageQAException. It uses bb.error instead. The best solution might be to migrate to the oe.qa.handle_error function, except it might break existing image qa checks in other layers. Making ImageQAFailed inherit from BBHandledException would make better_exec ignore it. But that would mean importing bb.utils into oe.utils which currently only imports standard library modules. Making better_exec aware of ImageQAFailed would reverse the import problem and better_exec should not need to know about image_qa specifics. A more pythonic option might be to implement some kind of protocol where we make Exceptions indicate their bbhandled status with a object property somehow.
I'd accept a patch to make ImageQAFailed inherit BBHandledException, that seems reasonable. I also agree we should move to the oe.qa.handle_error function. I'm not too worried about backwards compatibility for this code.
Fixed by 905e224849fbbed1719e0add231b00e2d570b3b4