Skip to content

Commit

Permalink
terror: address comment and add update class String method.
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood committed Nov 5, 2015
1 parent 83ac08b commit c6c74b6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 35 deletions.
31 changes: 0 additions & 31 deletions terror/codes.go

This file was deleted.

30 changes: 26 additions & 4 deletions terror/terror.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,35 @@ package terror

import (
"fmt"
"github.com/juju/errors"
"strconv"
)

// ErrClass represents a class of errors.
type ErrClass int
"github.com/juju/errors"
)

// ErrCode represents a specific error type in a error class.
// Same error code can be used in different error classes.
type ErrCode int

// Schema error codes
const (
DatabaseNotExists ErrCode = iota + 1
)

// Executor error codes
const (
CommitNotInTransaction ErrCode = iota + 1
RollbackNotInTransaction
)

// KV error codes
const (
IncompatibleDBFormat ErrCode = iota + 1
NoDataForHandle
)

// ErrClass represents a class of errors.
type ErrClass int

// Error classes
const (
Parser ErrClass = iota + 1
Expand All @@ -42,8 +60,12 @@ func (ec ErrClass) String() string {
switch ec {
case Parser:
return "parser"
case Schema:
return "schema"
case Optimizer:
return "optimizer"
case Executor:
return "executor"
case KV:
return "kv"
case Server:
Expand Down

0 comments on commit c6c74b6

Please sign in to comment.