move all error things to new qerr package, replacing errorcodes

This commit is contained in:
Lucas Clemente
2016-05-17 10:24:34 +02:00
parent 62da35d613
commit bfaa4200df
12 changed files with 71 additions and 66 deletions

View File

@@ -1,27 +0,0 @@
package protocol
import (
"fmt"
"github.com/lucas-clemente/quic-go/errorcodes"
)
// A QuicError is a QUIC error
type QuicError struct {
ErrorCode errorcodes.ErrorCode
ErrorMessage string
}
// Error creates a new Quic Error
func Error(errorCode errorcodes.ErrorCode, errorMessage string) *QuicError {
return &QuicError{
ErrorCode: errorCode,
ErrorMessage: errorMessage,
}
}
func (e *QuicError) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode.String(), e.ErrorMessage)
}
var _ error = &QuicError{}

View File

@@ -1,16 +0,0 @@
package protocol_test
import (
"github.com/lucas-clemente/quic-go/errorcodes"
"github.com/lucas-clemente/quic-go/protocol"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Quic error", func() {
It("has a string representation", func() {
err := protocol.Error(errorcodes.InternalError, "foobar")
Expect(err.Error()).To(Equal("InternalError: foobar"))
})
})