PUP-3561 add exception catch and wrapping into known exception type

I can't find where `msg` is initially declared