Feature #20669
Updated by olleolleolle (Olle Jonsson) 5 months ago
## Abstract Add a `Marshal::MarshalError` error class to be raised on failing to load data. ## Background Currently, `ArgumentError` is raised when failing to load data. ## Proposal Add a `Marshal::MarshalError` error class to be raised Marshal.load raises ArgumentErrors on failing to load data. failure. ## Use cases Dalli tries to differentiate errors that have to do with Marshal.load by pattern-matching on "message" in these ArgumentError instances. If In the memcache client Dalli, there were a way to tell "this was Marshal.load failing", it'd be nice. Example: is [a regular expression to check for a few of the ArgumentErrors that can be raised during Marshal.load](https://github.com/petergoldstein/dalli/blob/v3.2.8/lib/dalli/protocol/value_serializer.rb#L41). ## Discussion In order to make it easier to work with, perhaps a new error class deriving from ArgumentError could be introduced in Marshal? Say, Marshal::MarshalError deriving from ArgumentError? Something backwards-compatible. ... ## See also [Dalli PR where another error message would be added](https://github.com/petergoldstein/dalli/pull/1008)