Reputation: 1085
my wired situation is, the online service is working now, and everyday i can find a few 500
error reports like below:
2018-12-19 00:00:01 [ERROR] path[/vplay/getIdsInfo/?type=vlist&ids=31105228] err[runtime error: index out of range] stack[
goweb.(*RouterTab).ServeHTTP.func3.1:/home/tanxiaolong/golib/src/goweb/router.go:352
runtime.call64:/usr/local/go/src/runtime/asm_amd64.s:574
runtime.gopanic:/usr/local/go/src/runtime/panic.go:505
runtime.panicindex:/usr/local/go/src/runtime/panic.go:28
models.(*VplayModel).AssembleData:/home/tanxiaolong/golib/src/vplay/models/vplay.go:757
controllers.(*VplayController).GetIdsInfoAction:/home/tanxiaolong/golib/src/vplay/controllers/vplay.go:652
runtime.call32:/usr/local/go/src/runtime/asm_amd64.s:573
reflect.Value.call:/usr/local/go/src/reflect/value.go:447
reflect.Value.Call:/usr/local/go/src/reflect/value.go:308
goweb.(*RouterTab).ServeHTTP.func3:/home/tanxiaolong/golib/src/goweb/router.go:370
runtime.goexit:/usr/local/go/src/runtime/asm_amd64.s:2361] (goweb/router.go:353)
i can find which api by log, but it returns 200
and correct response data if request it with the same query data as 500
requests by myself or wrk or ab.
i don't know how to debug this bug..
any suggestions on api debugging??
many thanks!
Upvotes: 2
Views: 996
Reputation: 1171
When you're handling errors you can use:
err.(*errors.Error).ErrorStack()
to return the stacktrace. With that you can get the line in which your API in some cases gets an index out of range error.
Upvotes: 2