How to handle OmmInvalidUsageException: Attempt to real() while entry data is blank. (C#)

We are extract fields from Refinitiv real-time data like this:

foreach (var field in updateMsg.Payload().FieldList())
{
switch (field.FieldId)
{
case 3:
Sym = field.OmmRmtesValue().ToString();
break;
case 19:
Open = field.OmmRealValue().AsDouble();
break;
...
}

The problem is, we encounter the following error message from time to time:

Unhandled exception. Exception Type='OmmInvalidUsageException', Text='Attempt to real() while entry data is blank.', Error Code='-4048'

How can we handle it? I check member functions/variables of field of updateMsg.Payload(), seems there isnt something like "HasValue" for me to call?

Best Answer

  • Gurpreet
    Answer ✓

    Hello @vnaik01,

    The application code should first check to see if the data is not-blank before it tries to decode its payload. The example 290 of the EMA C# SDK shows, how this can be implemented in the code:

    if (Data.DataCode.BLANK != fieldEntry.Code)
    ...