MCPcopy Create free account
hub / github.com/SoarGroup/Soar / AddErrorToSMLResponse

Method AddErrorToSMLResponse

Core/ConnectionSML/src/sml_Connection.cpp:1014–1053  ·  view source on GitHub ↗

* @brief Adds an tag and an error message to a response message. * * @param pResponse The response message we are adding an error to. * @param pErrorMsg A description of the error in a form presentable to the user * @param errorCode An optional numeric code for the error (to support programmatic responses to the error) *************************************************************/

Source from the content-addressed store, hash-verified

1012* @param errorCode An optional numeric code for the error (to support programmatic responses to the error)
1013*************************************************************/
1014void Connection::AddErrorToSMLResponse(ElementXML* pResponse, char const* pErrorMsg, int errorCode /* = -1 */)
1015{
1016 ClearError() ;
1017
1018#ifdef DEBUG
1019 if (!pResponse || !pErrorMsg)
1020 {
1021 SetError(Error::kNullArgument) ;
1022 return ;
1023 }
1024
1025 if (!pResponse->IsTag(sml_Names::kTagSML))
1026 {
1027 SetError(Error::kArgumentIsNotSML) ;
1028 return ;
1029 }
1030#endif
1031 // Create a result tag so if you only
1032 // check for results you still get an error message.
1033 // Also add an error tag, so we can distinguish between
1034 // errors and success based on message structure.
1035 TagResult* pTag = new TagResult() ;
1036
1037 pTag->SetCharacterData(pErrorMsg) ;
1038 pTag->AddAttributeFastFast(sml_Names::kCommandOutput, sml_Names::kRawOutput) ;
1039
1040 pResponse->AddChild(pTag) ;
1041
1042 // Create the error tag
1043 TagError* pError = new TagError() ;
1044
1045 pError->SetDescription(pErrorMsg) ;
1046
1047 if (errorCode != -1)
1048 {
1049 pError->SetErrorCode(errorCode) ;
1050 }
1051
1052 pResponse->AddChild(pError) ;
1053}
1054
1055/*************************************************************
1056* @brief Adds a <result> tag and fills in character data for that result.

Callers 2

GetLastResultSMLMethod · 0.80
AddErrorMsgFunction · 0.80

Calls 7

SetErrorFunction · 0.85
IsTagMethod · 0.80
SetCharacterDataMethod · 0.80
AddAttributeFastFastMethod · 0.80
AddChildMethod · 0.45
SetDescriptionMethod · 0.45
SetErrorCodeMethod · 0.45

Tested by

no test coverage detected