Example #1
0
func exitWithNotImplementedError(err error) {
	fmt.Println(bosh.BuildErrorResponse(err, bosh.NotImplementedErrorType, false, responseLogBuffer.String()))
	responseLogBuffer.Reset()
	os.Exit(1)
}
			Expect(targetResponse.Result).To(BeNil())
			Expect(targetResponse.Log).To(BeEmpty())

			targetResponseErr := targetResponse.Error
			Expect(targetResponseErr.Type).To(Equal(bosh.DefaultErrorType))
			Expect(targetResponseErr.Message).To(Equal(testErrMsg))
			Expect(targetResponseErr.Retryable).To(BeFalse())
		})
	})

	Describe("exiting with a custom error", func() {
		It("wraps custom errors in a CpiResponse", func() {
			testErrMsg := "a test error"
			testErr := errors.New(testErrMsg)
			errResp := bosh.BuildErrorResponse(testErr, bosh.NotImplementedErrorType, false, "")
			errRespBytes := []byte(errResp)

			targetResponse := bosh.CpiResponse{}
			err := json.Unmarshal(errRespBytes, &targetResponse)
			Expect(err).ToNot(HaveOccurred())

			Expect(targetResponse.Result).To(BeNil())
			Expect(targetResponse.Log).To(BeEmpty())

			targetResponseErr := targetResponse.Error
			Expect(targetResponseErr.Type).To(Equal(bosh.NotImplementedErrorType))
			Expect(targetResponseErr.Message).To(Equal(testErrMsg))
			Expect(targetResponseErr.Retryable).To(BeFalse())
		})
	})