gorilla / schema

Package gorilla/schema fills a struct with form values.
https://gorilla.github.io
BSD 3-Clause "New" or "Revised" License
1.39k stars 231 forks source link

Remove log.Fatal() usage in encoder.go #207

Closed h2570su closed 10 months ago

h2570su commented 1 year ago

What type of PR is this? (check all applicable)

Description

Related Tickets & Documents

Added/updated tests?

Run verifications and test

AlexVulaj commented 1 year ago

Hi @h2570su , thanks for contributing! Could you provide a bit more information about why this change is necessary or what problems it solves?

h2570su commented 1 year ago

log.Fatal() exits the program immediately. In my opinion, that should been used only if the error is unrecoverable and critical enough. And shouldn't been used in a library because a main program maybe using a different logger implementation, exiting program by std library logger could be hard to trace the location error occurred.

The encoder is returning error, the procedure encoder during reflection fails won't harms whole program. Returning a error to top-level is enough.

jaitaiwan commented 10 months ago

Merged, Thanks for the contribution @h2570su!