Skip to content
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

fix: play panic recover #238

Merged
merged 6 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Types of changes
## [1.18.1]

- `Fixed` local seed parameter should be consistent between different jsonpath
- `Fixed` PIMO Play web assembly version handle panics and recover gracefully when panics occure
- `Fixed` PIMO Play handle panics and recover gracefully when panics occure

## [1.18.0]

Expand Down
18 changes: 18 additions & 0 deletions internal/app/pimo/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ func Play(enableSecurity bool) *echo.Echo {

// play binds client interface data entry to be processed and returns the transformed json to client
func play(ctx echo.Context) error {
// dont't panic
defer func() error {
if r := recover(); r != nil {
log.Error().AnErr("panic", r.(error)).Msg("Recovering from panic in play.")
return ctx.String(http.StatusInternalServerError, r.(error).Error())
}
return nil
}() //nolint:errcheck

config := Config{
EmptyInput: false,
RepeatUntil: "",
Expand Down Expand Up @@ -110,6 +119,15 @@ func play(ctx echo.Context) error {
}

func flowchart(ctx echo.Context) error {
// dont't panic
defer func() error {
if r := recover(); r != nil {
log.Error().AnErr("panic", r.(error)).Msg("Recovering from panic in play.")
adrienaury marked this conversation as resolved.
Show resolved Hide resolved
return ctx.String(http.StatusInternalServerError, r.(error).Error())
}
return nil
}() //nolint:errcheck

var dataInput map[string]interface{}

err := ctx.Bind(&dataInput)
Expand Down
5 changes: 3 additions & 2 deletions web/play/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# dependencies
/node_modules
!/node_modules/go.mod
/.pnp
.pnp.js

Expand All @@ -23,6 +24,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Elm
# Elm
elm-stuff/
gen/
gen/
Empty file added web/play/node_modules/go.mod
Empty file.