本文整理汇总了Golang中github.com/luci/luci-go/common/errors.SingleError函数的典型用法代码示例。如果您正苦于以下问题:Golang SingleError函数的具体用法?Golang SingleError怎么用?Golang SingleError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SingleError函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestBrokenFeatures
func TestBrokenFeatures(t *testing.T) {
t.Parallel()
e := errors.New("default err")
Convey("BrokenFeatures", t, func() {
c := memory.Use(context.Background())
Convey("Can break ds", func() {
Convey("without a default", func() {
c, bf := FilterRDS(c, nil)
ds := datastore.Get(c)
vals := []datastore.PropertyMap{{
"$key": {datastore.MkPropertyNI(ds.NewKey("Wut", "", 1, nil))},
}}
Convey("by specifying an error", func() {
bf.BreakFeatures(e, "GetMulti", "PutMulti")
So(ds.GetMulti(vals), ShouldEqual, e)
Convey("and you can unbreak them as well", func() {
bf.UnbreakFeatures("GetMulti")
So(errors.SingleError(ds.GetMulti(vals)), ShouldEqual, datastore.ErrNoSuchEntity)
Convey("no broken features at all is a shortcut", func() {
bf.UnbreakFeatures("PutMulti")
So(errors.SingleError(ds.GetMulti(vals)), ShouldEqual, datastore.ErrNoSuchEntity)
})
})
})
Convey("Not specifying an error gets you a generic error", func() {
bf.BreakFeatures(nil, "GetMulti")
So(ds.GetMulti(vals).Error(), ShouldContainSubstring, `feature "GetMulti" is broken`)
})
})
Convey("with a default", func() {
c, bf := FilterRDS(c, e)
ds := datastore.Get(c)
vals := []datastore.PropertyMap{{
"$key": {datastore.MkPropertyNI(ds.NewKey("Wut", "", 1, nil))},
}}
bf.BreakFeatures(nil, "GetMulti")
So(ds.GetMulti(vals), ShouldEqual, e)
})
})
})
}
示例2: Delete
func (d *datastoreImpl) Delete(key Key) (err error) {
return errors.SingleError(d.DeleteMulti([]Key{key}))
}
示例3: Put
func (d *datastoreImpl) Put(src interface{}) (err error) {
if !isOkType(reflect.TypeOf(src)) {
return fmt.Errorf("invalid Put input type: %T", src)
}
return errors.SingleError(d.PutMulti([]interface{}{src}))
}
示例4: Get
func (d *datastoreImpl) Get(dst interface{}) (err error) {
if !isOkType(reflect.TypeOf(dst)) {
return fmt.Errorf("invalid Get input type: %T", dst)
}
return errors.SingleError(d.GetMulti([]interface{}{dst}))
}
示例5: Delete
func (t *taskqueueImpl) Delete(task *Task, queueName string) error {
return errors.SingleError(t.DeleteMulti([]*Task{task}, queueName))
}
示例6: Add
func (t *taskqueueImpl) Add(task *Task, queueName string) error {
return errors.SingleError(t.AddMulti([]*Task{task}, queueName))
}
示例7: CompareAndSwap
func (m *memcacheImpl) CompareAndSwap(item Item) error {
return errors.SingleError(m.CompareAndSwapMulti([]Item{item}))
}
示例8: Get
func (m *memcacheImpl) Get(item Item) error {
return errors.SingleError(m.GetMulti([]Item{item}))
}
示例9: Delete
func (m *memcacheImpl) Delete(key string) error {
return errors.SingleError(m.DeleteMulti([]string{key}))
}
示例10: Add
func (m *memcacheImpl) Add(item Item) error {
return errors.SingleError(m.AddMulti([]Item{item}))
}
示例11: Put
func (d *datastoreImpl) Put(src interface{}) (err error) {
if err := isOkType(reflect.TypeOf(src)); err != nil {
panic(fmt.Errorf("invalid Put input type (%T): %s", src, err))
}
return errors.SingleError(d.PutMulti([]interface{}{src}))
}
示例12: Get
func (d *datastoreImpl) Get(dst interface{}) (err error) {
if err := isOkType(reflect.TypeOf(dst)); err != nil {
panic(fmt.Errorf("invalid Get input type (%T): %s", dst, err))
}
return errors.SingleError(d.GetMulti([]interface{}{dst}))
}
示例13: Exists
func (d *datastoreImpl) Exists(k *Key) (bool, error) {
ret, err := d.ExistsMulti([]*Key{k})
return ret[0], errors.SingleError(err)
}
示例14: Get
func (m *memcacheImpl) Get(key string) (Item, error) {
ret := m.NewItem(key)
err := errors.SingleError(m.GetMulti([]Item{ret}))
return ret, err
}