Skip to content

The main focus is on optimizing the error tracking functionality to obtain precise error locations. #93

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions gee-orm/day3-save-query/session/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
// Insert one or more records in database
func (s *Session) Insert(values ...interface{}) (int64, error) {
recordValues := make([]interface{}, 0)
table := s.Model(values[0]).RefTable()
s.clause.Set(clause.INSERT, table.Name, table.FieldNames)
for _, value := range values {
table := s.Model(value).RefTable()
s.clause.Set(clause.INSERT, table.Name, table.FieldNames)
recordValues = append(recordValues, table.RecordValues(value))
}

Expand Down
1 change: 0 additions & 1 deletion gee-orm/day5-hooks/session/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ func (s *Session) CallMethod(method string, value interface{}) {
}
}
}
return
}
25 changes: 20 additions & 5 deletions gee-web/day7-panic-recover/gee/recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,30 @@ import (

// print stack trace for debug
func trace(message string) string {
// Allocate an array to store program counters
var pcs [32]uintptr
n := runtime.Callers(3, pcs[:]) // skip first 3 caller
// Get call stack info, skip first 3 callers
n := runtime.Callers(3, pcs[:])

var str strings.Builder
str.WriteString(message + "\nTraceback:")
for _, pc := range pcs[:n] {
fn := runtime.FuncForPC(pc)
file, line := fn.FileLine(pc)
str.WriteString(fmt.Sprintf("\n\t%s:%d", file, line))

// Create Frames object
frames := runtime.CallersFrames(pcs[:n])
for {
// Get one frame per iteration
frame, more := frames.Next()

// Add file, line number and function name
str.WriteString(fmt.Sprintf("\n\t%s:%d - %s",
frame.File,
frame.Line,
frame.Function,
))

if !more {
break
}
}
return str.String()
}
Expand Down