示例#1
0
// MarshalBottlePayload validates and renders an instance of BottlePayload into a interface{}
func MarshalBottlePayload(source *BottlePayload, inErr error) (target map[string]interface{}, err error) {
	err = inErr
	if err2 := source.Validate(); err2 != nil {
		err = goa.ReportError(err, err2)
		return
	}
	tmp37 := map[string]interface{}{
		"color":     source.Color,
		"country":   source.Country,
		"name":      source.Name,
		"region":    source.Region,
		"review":    source.Review,
		"sweetness": source.Sweetness,
		"varietal":  source.Varietal,
		"vineyard":  source.Vineyard,
		"vintage":   source.Vintage,
	}
	target = tmp37
	return
}
示例#2
0
			Ω(tErr.Mesg).Should(ContainSubstring(fmt.Sprintf("%#v", target)))
		})
	})
})

var _ = Describe("ReportError", func() {
	var err, err2 error
	var mErr error

	BeforeEach(func() {
		err = nil
		err2 = nil
	})

	JustBeforeEach(func() {
		mErr = goa.ReportError(err, err2)
	})

	Context("with two nil errors", func() {
		It("returns an empty error", func() {
			Ω(mErr).Should(BeAssignableToTypeOf(goa.MultiError{}))
			Ω(mErr).Should(BeEmpty())
		})
	})

	Context("with the second error nil", func() {
		Context("with the first argument a MultiError", func() {
			BeforeEach(func() {
				err = goa.MultiError{errors.New("foo")}
			})