Handle error from GetDevice early

Also more verbose error.

Fixes panic from #7701

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
Merge pull request #7702 from LK4D4/fix_panic_on_bad_device_#7701

Handle error from GetDevice early