application controller: clean up exception handling.
* Simplify code. * Show backtraces for all users, not just builders. * Show backtraces only for unexpected server errors (status 5xx), not for normal client errors (status 4xx). * Log expected errors at info level (reduce noise in production logs).
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
class DanbooruLogger
|
||||
def self.log(exception, expected: false, **params)
|
||||
if !expected
|
||||
if expected
|
||||
Rails.logger.info("#{exception.class}: #{exception.message}")
|
||||
else
|
||||
backtrace = Rails.backtrace_cleaner.clean(exception.backtrace).join("\n")
|
||||
Rails.logger.error("#{exception.class}: #{exception.message}\n#{backtrace}")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user