profiler: Simplify code for class name mapping

Follows-up 000c6529d. Handle errors first.

Change-Id: I70308783a2e8b140b3c850758cce36544b32eb20
Merge "profiler: Simplify code for class name mapping"