Skip to content

Commit

Permalink
Use recover() directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekuruu committed Oct 27, 2024
1 parent d424405 commit 770b1d4
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions hnet/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func ReadLoginRequest(stream *common.IOStream) *LoginRequest {
defer handlePanic()
defer recover()

username := stream.ReadString()
password := stream.ReadString()
Expand All @@ -34,7 +34,7 @@ func ReadLoginRequest(stream *common.IOStream) *LoginRequest {
}

func ReadLoginRequestReconnect(stream *common.IOStream) *LoginRequest {
defer handlePanic()
defer recover()

username := stream.ReadString()
password := stream.ReadString()
Expand Down Expand Up @@ -82,7 +82,7 @@ func ParseClientInfo(clientInfoString string) *ClientInfo {
}

func ReadStatusChange(stream *common.IOStream) *Status {
defer handlePanic()
defer recover()

status := &Status{
UserId: stream.ReadU32(),
Expand All @@ -106,15 +106,15 @@ func ReadStatusChange(stream *common.IOStream) *Status {
}

func ReadStatsRequest(stream *common.IOStream) *StatsRequest {
defer handlePanic()
defer recover()

return &StatsRequest{
UserIds: stream.ReadIntList(),
}
}

func ReadRelationshipRequest(stream *common.IOStream) *RelationshipRequest {
defer handlePanic()
defer recover()

status := common.StatusBlocked
isFriend := stream.ReadBool()
Expand All @@ -129,7 +129,3 @@ func ReadRelationshipRequest(stream *common.IOStream) *RelationshipRequest {
UserId: userId,
}
}

func handlePanic() {
_ = recover()
}

0 comments on commit 770b1d4

Please sign in to comment.