안녕하세요, 저는 이 방법을 권하지 않습니다. 일반적인 로깅은 왜 안 쓰시나요? 문제의 줄을 찾는 데 시간이 오래 걸리는 게 문제라면 저도 겪어봤습니다.
제 http 오류 응답 코드를 붙입니다. 비슷한 방식을 쓰면 실패 원인을 바로 찾을 수 있습니다.
type FailureReply struct {
Detail string `json:"detail"` // My own explanaton of why this happened.
Error string `json:"error"`
}
permissions, lookupErr := service.Queries.GetPurePermissionsByUserId(context.Background(), member.ID)
if lookupErr != nil {
helpers.RespondWithJSON(writer, helpers.FailureReply{
Detail: "Could not retrieve member permissions",
Error: lookupErr.Error(),
})
return
}
영어에서 번역·원문 보기Hi, this isn't something I'd advise. Why aren't you using ordinary logging? If locating the line takes you ages and that is the difficulty, I've run into that too.
Here's my http error response code, though a similar approach lets you immediately locate whatever caused the failure.
type FailureReply struct {
Detail string `json:"detail"` // My own explanaton of why this happened.
Error string `json:"error"`
}
permissions, lookupErr := service.Queries.GetPurePermissionsByUserId(context.Background(), member.ID)
if lookupErr != nil {
helpers.RespondWithJSON(writer, helpers.FailureReply{
Detail: "Could not retrieve member permissions",
Error: lookupErr.Error(),
})
return
}