Skip to content

Commit

Permalink
Made errorFrame an interface that can implemented by the different ty…
Browse files Browse the repository at this point in the history
…pes of errors from a cassandra server.
  • Loading branch information
nemosupremo committed May 1, 2014
1 parent e617f1d commit 0879b50
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package gocql

const (
errServer = 0x0000
errProtocol = 0x000A
errCredentials = 0x0100
errUnavailable = 0x1000
errOverloaded = 0x1001
errBootstrapping = 0x1002
errTruncate = 0x1003
errWriteTimeout = 0x1100
errReadTimeout = 0x1200
errSyntax = 0x2000
errUnauthorized = 0x2100
errInvalid = 0x2200
errConfig = 0x2300
errAlreadyExists = 0x2400
errUnprepared = 0x2500
)

type errorFrame interface {
Code() int
Message() string
Error() string
}

type errorResponse struct {
code int
message string
}

func (e errorResponse) Code() int {
return e.code
}

func (e errorResponse) Message() string {
return e.message
}

func (e errorResponse) Error() string {
return e.Message()
}

type errRespUnavailable struct {
errorResponse
Consistency Consistency
Required int
Alive int
}

type errRespWriteTimeout struct {
errorResponse
Consistency Consistency
Received int
BlockFor int
WriteType string
}

type errRespReadTimeout struct {
errorResponse
Consistency Consistency
Received int
BlockFor int
DataPresent byte
}

type errRespAlreadyExists struct {
errorResponse
Keyspace string
Table string
}

type errRespUnprepared struct {
errorResponse
StatementId []byte
}

0 comments on commit 0879b50

Please sign in to comment.