- 
    Type:Bug 
- 
    Resolution: Fixed
- 
    Priority:Major - P3 
- 
    Affects Version/s: None
- 
    Component/s: Internal Code
- 
        Fully Compatible
- 
        ALL
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
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.
- duplicates
- 
                    SERVER-50639 Improve function "const T* mongo::Status::extraInfo()" to support errors with optional extraInfo -         
- Closed
 
-         
- related to
- 
                    SERVER-52904 Improve implementation of mongo::Status -         
- Closed
 
-