MCPcopy
hub / github.com/wavetermdev/waveterm / convertReturnValues

Function convertReturnValues

pkg/service/service.go:275–309  ·  view source on GitHub ↗
(rtnVals []reflect.Value)

Source from the content-addressed store, hash-verified

273}
274
275func convertReturnValues(rtnVals []reflect.Value) *WebReturnType {
276 rtn := &WebReturnType{}
277 if len(rtnVals) == 0 {
278 return rtn
279 }
280 for _, val := range rtnVals {
281 if isNilable(val) && val.IsNil() {
282 continue
283 }
284 valType := val.Type()
285 if valType == errorRType {
286 rtn.Error = val.Interface().(error).Error()
287 continue
288 }
289 if valType == updatesRType {
290 // has a special MarshalJSON method
291 rtn.Updates = val.Interface().([]waveobj.WaveObjUpdate)
292 continue
293 }
294 if isSpecialWaveArgType(valType) {
295 jsonVal, err := convertSpecialForReturn(valType, val.Interface())
296 if err != nil {
297 rtn.Error = fmt.Errorf("cannot convert special return value: %v", err).Error()
298 continue
299 }
300 rtn.Data = jsonVal
301 continue
302 }
303 rtn.Data = val.Interface()
304 }
305 if rtn.Error == "" {
306 rtn.Success = true
307 }
308 return rtn
309}
310
311func webErrorRtn(err error) *WebReturnType {
312 return &WebReturnType{

Callers 1

CallServiceFunction · 0.85

Calls 5

isNilableFunction · 0.85
isSpecialWaveArgTypeFunction · 0.85
convertSpecialForReturnFunction · 0.85
TypeMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected