func tabletErrorFromVitessError(ve *vterrors.VitessError) error { // see if the range is in the tablet error range if ve.Code >= vterrors.TabletError && ve.Code <= vterrors.UnknownTabletError { return &tabletconn.ServerError{ Code: int(ve.Code - vterrors.TabletError), Err: fmt.Sprintf("vttablet: %v", ve.Error()), } } return tabletconn.OperationalError(fmt.Sprintf("vttablet: %v", ve.Message)) }
func tabletErrorFromVitessError(ve *vterrors.VitessError) error { var code int switch ve.Code { case vtrpc.ErrorCode_INTERNAL_ERROR: code = tabletconn.ERR_FATAL case vtrpc.ErrorCode_QUERY_NOT_SERVED: code = tabletconn.ERR_RETRY case vtrpc.ErrorCode_RESOURCE_EXHAUSTED: code = tabletconn.ERR_TX_POOL_FULL case vtrpc.ErrorCode_NOT_IN_TX: code = tabletconn.ERR_NOT_IN_TX default: code = tabletconn.ERR_NORMAL } return &tabletconn.ServerError{Code: code, Err: fmt.Sprintf("vttablet: %v", ve.Error())} }