// Get body data (parsed). // // @param to interface{} // @return interface{}, error func (this *Stream) GetBodyData(to interface{}) (interface{}, error) { // error? if this.Error != "" { data, err := util.ParseBody(this.Body.(string), &StreamError{}) if err != nil { return nil, err } return nil, _fmt.Errorf("Stream Error >> error: \"%s\", reason: \"%s\"", data.(*StreamError).ErrorKey, data.(*StreamError).ErrorValue, ) } data, err := util.ParseBody(this.Body.(string), to) if err != nil { return nil, err } return data, nil }
// Set error. // // @param body string // @return void func (this *Stream) SetError(body string) { if body == "" { body = this.Body.(string) } data, err := util.ParseBody(body, &StreamError{}) if data != nil && err == nil { errorKey := data.(*StreamError).ErrorKey errorValue := data.(*StreamError).ErrorValue this.Error = _fmt.Sprintf("Stream Error >> error: \"%s\", reason: \"%s\"", errorKey, errorValue, ) this.ErrorData = util.MapString() this.ErrorData["error"] = errorKey this.ErrorData["reason"] = errorValue } }