From: "Dan0042 (Daniel DeLorme) via ruby-core" Date: 2024-01-08T20:56:25+00:00 Subject: [ruby-core:116084] [Ruby master Feature#20164] Add Exception#deconstruct_keys Issue #20164 has been reported by Dan0042 (Daniel DeLorme). ---------------------------------------- Feature #20164: Add Exception#deconstruct_keys https://bugs.ruby-lang.org/issues/20164 * Author: Dan0042 (Daniel DeLorme) * Status: Open * Priority: Normal ---------------------------------------- It would be convenient to perform pattern matching with exception classes. So `Exception#deconstruct_keys` should return a hash with `:message` (original_message) as well as any other keys specific to the exception subclass. Examples: ``` begin #code rescue => err case err in StandardError(message: /Permission denied/) abort "please select a different file" in NameError(name: :foo) retry if require "foo_helper else raise end end ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/