Compare commits

...

2 Commits

Author SHA1 Message Date
Trịnh Đức Bảo Linh(Kevin)
92973d6add feat(*): update CHANGELOG.md file (#708)
* error panic handling

* updated CHANGELOG.md file

* correct msg panic error (#5)

* fix(typo): delete-all to deleteall (#827)

* typo: delete-all to deleteall

* docs: update tools/asynq/README.md

* fix archiveall runall

---------

Co-authored-by: Mohamed Sohail <sohailsameja@gmail.com>

* Fixed go:build for BSD

* chore: fix function names in comment

Signed-off-by: camcui <cuishua@sina.cn>

---------

Signed-off-by: camcui <cuishua@sina.cn>
Co-authored-by: crazyoptimist <me@crazyoptimist.net>
Co-authored-by: Mohamed Sohail <sohailsameja@gmail.com>
Co-authored-by: mrusme <marius@xn--gckvb8fzb.com>
Co-authored-by: camcui <cuishua@sina.cn>
2024-05-06 14:12:42 +08:00
Mohammed Sohail
4c5202ee13 docs (CHANGELOG): IsPanicError function (closes #708) 2024-01-29 11:33:46 +03:00
2 changed files with 7 additions and 6 deletions

View File

@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- `IsPanicError` function is added to support catching of panic errors when processing tasks (PR: https://github.com/hibiken/asynq/pull/491)
## [0.24.1] - 2023-05-01
### Changed

View File

@@ -415,21 +415,19 @@ func (p *processor) queues() []string {
func (p *processor) perform(ctx context.Context, task *Task) (err error) {
defer func() {
if x := recover(); x != nil {
errMsg := string(debug.Stack())
p.logger.Errorf("recovering from panic. See the stack trace below for details:\n%s", errMsg)
p.logger.Errorf("recovering from panic. See the stack trace below for details:\n%s", string(debug.Stack()))
_, file, line, ok := runtime.Caller(1) // skip the first frame (panic itself)
if ok && strings.Contains(file, "runtime/") {
// The panic came from the runtime, most likely due to incorrect
// map/slice usage. The parent frame should have the real trigger.
_, file, line, ok = runtime.Caller(2)
}
var errMsg string
// Include the file and line number info in the error, if runtime.Caller returned ok.
if ok {
err = fmt.Errorf("panic [%s:%d]: %v", file, line, x)
errMsg = fmt.Sprintf("panic [%s:%d]: %v", file, line, x)
} else {
err = fmt.Errorf("panic: %v", x)
errMsg = fmt.Sprintf("panic: %v", x)
}
err = &errors.PanicError{
ErrMsg: errMsg,