Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-52741

Avoid invariant when trying to get optional ErrorExtraInfo

    • Fully Compatible
    • ALL

      The only way to get errors' extra info is by calling errStatus.extraInfo<TypeOfExtraInfo>() but - if no extraInfo is present - this invariant is hit.
       
      The usual pattern to get extra info is:

      if(errStatus.code == XYZ-Error-Code-I-Definitely-Know-Has-Extra-Info){
         auto extraInfo = errStatus.extraInfo<XYZExtraInfo>();
         ......
      }
      

      However, after the introduction of optional extra info, there is no way to get it just if present.
       
      Currently, the only way of dealing with that is to be 100% sure that the exception carries it or not. That - in other words - means knowing all the possible points where the exception can come from.

            Assignee:
            pierlauro.sciarelli@mongodb.com Pierlauro Sciarelli
            Reporter:
            pierlauro.sciarelli@mongodb.com Pierlauro Sciarelli
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: