Yes the previous code only reports a condition in which no custom data key exists.
The following catches missing data for an existing key (in 1.5)
Code:
tell application "OmniPlan"
set oTask to item 1 of child tasks of document 1
set recData to custom data of oTask
set varValue to |OPBug_ID| of recData
if varValue is missing value then
display dialog "Empty !"
else
display dialog (varValue as string)
end if
end tell