
Issue #20864 has been updated by ioquatix (Samuel Williams). Thanks for your feedback. The proposal is deliberately thin - as I said, I don't know exactly how we should adjust the internal interface to handle this (actually I don't have a strong opinion about it). The main point is, to allow for an additional keyword argument. I think `Warning.warn` should probably receive that keyword argument, and maybe print it using `error.full_message` or something similar. I don't think it should be part of `formatted_str` but I think the default implementation could print it separately? ---------------------------------------- Feature #20864: Support `error:` keyword to `Kernel#warn` https://bugs.ruby-lang.org/issues/20864#change-110418 * Author: ioquatix (Samuel Williams) * Status: Open ---------------------------------------- `Kernel#warn` is extremely useful. It is possible to include some details about the current caller using `uplevel` for the current call stack. But it is not possible to include details about errors. I'd like to propose another extension to log errors. ```ruby begin # some work rescue => error warn "An error occurred!", error: error end ``` Such a feature would allow us to log errors using a standard interface. I don't have an opinion about the implementation, but I wanted to get feedback on the interface. -- https://bugs.ruby-lang.org/