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

レスポンスとしてError()を返却する場合は根源のエラーのみを出力するように変更 #56

Open
task4233 opened this issue Mar 25, 2021 · 1 comment
Labels
change 仕様変更するとき

Comments

@task4233
Copy link
Collaborator

task4233 commented Mar 25, 2021

概要

レスポンスとしてクライアントにerr.Error()を返却する場合は、根源のエラーのみを出力するようにする。

このようなコードでは、echoのエラーレスポンスとして内部情報を公開してしまう可能性がある。

if errors.As(err, &entity.ErrNotFound{}) {
  return echo.NewHTTPError(http.StatusNotFound, err.Error())
}

そのため、下記のようなコードに変更する。

errNF := &entity.ErrNotFound{}
if errors.As(err, errNF) {
  return echo.NewHTTPError(http.StatusNotFound, errNF.Error())
}
@task4233 task4233 added the change 仕様変更するとき label Mar 25, 2021
@task4233 task4233 changed the title レスポンスとしてError()noを返却する場合は根源のエラーのみを出力するように変更 レスポンスとしてError()を返却する場合は根源のエラーのみを出力するように変更 Mar 25, 2021
@task4233
Copy link
Collaborator Author

ref: #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change 仕様変更するとき
Projects
None yet
Development

No branches or pull requests

1 participant