Skip to content

Add ErrPos() interface to OracleError, #621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions network/oracle_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ package network
type OracleError struct {
ErrCode int
ErrMsg string
errPos int
}

func (err *OracleError) Error() string {
return err.ErrMsg
}

// ErrPos return sql error position。
func (err *OracleError) ErrPos() int {
return err.errPos
}

func (err *OracleError) translate() {
switch err.ErrCode {
case 1:
Expand Down
1 change: 1 addition & 0 deletions network/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ func (session *Session) GetError() *OracleError {
} else {
err.ErrMsg = string(session.Summary.ErrorMessage)
}
err.errPos = session.Summary.errorPos
}
return err
}
Expand Down
6 changes: 6 additions & 0 deletions v2/network/oracle_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
type OracleError struct {
ErrCode int
ErrMsg string
errPos int
}

func (err *OracleError) Error() string {
Expand All @@ -17,6 +18,11 @@ func (err *OracleError) Error() string {
return err.ErrMsg
}

// ErrPos return sql error position。
func (err *OracleError) ErrPos() int {
return err.errPos
}

func (err *OracleError) translate() {
switch err.ErrCode {
case 1:
Expand Down
17 changes: 9 additions & 8 deletions v2/network/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func (session *Session) BreakConnection() error {
// return nil, err
// }
// } else {
//
//
// }
// ret := make([]PacketInterface, 0, 2)
// var pck PacketInterface
Expand Down Expand Up @@ -723,7 +723,7 @@ func (session *Session) processMarker() error {
// receive all packet until you get marker
// var pck PacketInterface = nil
// for pck == nil || pck.getPacketType() != MARKER {
//
//
// if session.isFinalPacketRead {
// break
// }
Expand Down Expand Up @@ -942,6 +942,7 @@ func (session *Session) GetError() *OracleError {
} else {
err.ErrMsg = string(session.Summary.ErrorMessage)
}
err.errPos = session.Summary.errorPos
}
return err
}
Expand Down Expand Up @@ -1345,7 +1346,7 @@ func (session *Session) readPacket() (PacketInterface, error) {
// default:
// return nil, errors.New(fmt.Sprintf("TTC error: received code %d during stmt reading", msg))
// }
//
//
// }
// fallthrough
default:
Expand Down Expand Up @@ -1706,7 +1707,7 @@ func (session *Session) GetClr() (output []byte, err error) {
// output, err = session.read(int(size))
// return
// }
//
//
// for {
// var size1 int
// if session.UseBigClrChunks {
Expand Down Expand Up @@ -1995,18 +1996,18 @@ func (session *Session) WriteKeyVal(buffer *bytes.Buffer, key []byte, val []byte
// }
// return ret, nil
// }
//
//
// func (session *Session) ReadInt(buffer *bytes.Buffer, size int, compress, bigEndian bool) (int, error) {
// temp, err := session.ReadInt64(buffer, size, compress, bigEndian)
// return int(temp), err
// }
//
//
// func (session *Session) ReadBytes(buffer *bytes.Buffer, size int) ([]byte, error) {
// temp := make([]byte, size)
// _, err := buffer.Read(temp)
// return temp, err
// }
//
//
// func (session *Session)ReadClr(buffer *bytes.Buffer) (output []byte, err error){
// var size uint8
// var rb []byte
Expand Down Expand Up @@ -2043,7 +2044,7 @@ func (session *Session) WriteKeyVal(buffer *bytes.Buffer, key []byte, val []byte
// output = tempBuffer.Bytes()
// return
// }
//
//
// func (session *Session)ReadDlc(buffer *bytes.Buffer) (output []byte, err error) {
// var length int
// length, err = session.ReadInt(buffer, 4, true, true)
Expand Down
Loading