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

Payloadを構築する関数をいくつか追加 #32

Merged
merged 3 commits into from
Dec 27, 2022
Merged

Conversation

fumieval
Copy link
Contributor

@fumieval fumieval commented Dec 26, 2022

showしてData.Text.packしてmessageを呼ぶというケースが多いので、それを行う関数を定義した

@fumieval fumieval changed the title Payloadwo Payloadを構築する関数をいくつか追加 Dec 26, 2022
@fumieval fumieval requested review from ruicc and ccycle December 26, 2022 11:26
messageException :: Exception e => e -> Payload
messageException e = messageShow e
<> "exception_type" .= show (typeOf e)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SomeExceptionの場合の関数もあると嬉しいかなとおもったんですがどうでしょうか?(なんとなく思っただけであまり使う場面が思い浮かばないですが)

messageSomeException :: SomeException -> Payload
messageSomeException (SomeException e) = messageShow e
  <> "exception_type" .= show (typeOf e)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SomeExceptionもExceptionのインスタンスであり、違いはtypeOfの結果が変わることくらいですが、SomeExceptionが来た場合は自動で内部のExceptionの型を表示するようにしました

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

関数を増やすよりこちらのほうがいいですね、ありがとうございます

@fumieval fumieval merged commit 86a4bc1 into master Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants