fix error string representation for errors without a message

This commit is contained in:
Marten Seemann
2019-03-07 09:53:13 +09:00
parent 7bd9844d38
commit ab47ba1021
2 changed files with 18 additions and 5 deletions

View File

@@ -8,11 +8,21 @@ import (
)
var _ = Describe("QUIC Transport Errors", func() {
Context("QuicError", func() {
It("has a string representation", func() {
err := Error(FlowControlError, "foobar")
Expect(err.Error()).To(Equal("FLOW_CONTROL_ERROR: foobar"))
})
It("has a string representation", func() {
err := Error(FlowControlError, "foobar")
Expect(err.Timeout()).To(BeFalse())
Expect(err.Error()).To(Equal("FLOW_CONTROL_ERROR: foobar"))
})
It("has a string representation for empty error phrases", func() {
err := Error(FlowControlError, "")
Expect(err.Error()).To(Equal("FLOW_CONTROL_ERROR"))
})
It("has a string representation for timeout errors", func() {
err := TimeoutError("foobar")
Expect(err.Timeout()).To(BeTrue())
Expect(err.Error()).To(Equal("NO_ERROR: foobar"))
})
Context("ErrorCode", func() {