< Previous by Date Date Index Next by Date >
  Thread Index  

[reSIProcate] avoiding an exception: SipMessage::header(const RequestLineType& l) const


Hello,

The following const function will cause an exception if mStartLine is null.
How is it possible to avoid calling this function if mStartline is null?

.exists(h_RequestLine) isn't applicable.  The only thing I could see is
caling isRequest(), but that is more of an implication than a concrete way
of determining if there is a RequestLine.

Thanks,

-Justin

const RequestLine& 
SipMessage::header(const RequestLineType& l) const
{
   assert (!isResponse());
   if (mStartLine == 0 )
   { 
      // request line missing
      assert(false);    
   }
   return
dynamic_cast<ParserContainer<RequestLine>*>(mStartLine->getParserContainer()
)->front();
}