[SERVER-52741] Avoid invariant when trying to get optional ErrorExtraInfo Created: 10/Nov/20  Updated: 29/Oct/23  Resolved: 16/Nov/20

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Bug Priority: Major - P3
Reporter: Pierlauro Sciarelli Assignee: Pierlauro Sciarelli
Resolution: Fixed Votes: 0
Labels: servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-50639 Improve function "const T* mongo::Sta... Closed
Related
related to SERVER-52904 Improve implementation of mongo::Status Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 16/Nov/20 ]

Author:

{'name': 'Pierlauro Sciarelli', 'email': 'pierlauro.sciarelli@mongodb.com', 'username': 'pierlauro'}

Message: SERVER-52741 Avoid invariant when trying to get optional ErrorExtraInfo
Branch: master
https://github.com/mongodb/mongo/commit/aa2b7d3eb58690778f8ea378afaa471beb65d491

Generated at Thu Feb 08 05:28:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.