Project

General

Profile

Actions

Feature #18915

open

New error class: NotImplementedYetError or scope change for NotImplementedError

Added by Quintasan (Michał Zając) almost 2 years ago. Updated 12 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:109207]

Description

Abstract

Introduce NotImplementedYetError exception that should be used in case when the codepath has not been implemented by the developer for some reason (maybe they're designing an abstract class or are designing some sort of interface to reuse later on) OR extend the meaning of NotImplementedError to cover those usecases so we don't have to introduce another exception

Background

NotImplementedError is supposed to be raised if the underlying operating system or Ruby runtime does not support them (https://ruby-doc.org/core-3.1.2/NotImplementedError.html)

However it appears that many people are misusing this exception by raising this in a superclass from which they later inherit from. I do realize that Ruby promotes duck-typing (the default RuboCop style guide has a cop for this – https://github.com/rubocop/ruby-style-guide#duck-typing). However I have seen this being discussed numerous times:

Proposal

Create NotImplementedYetError exception

OR

Allow raising NotImplementedError in cases other than OS or Ruby runtime incompatibilities

Evaluation

Add NotImplementedYetError

I think a new exception is a better idea than changing the usage of an existing one just because "everyone is using it". That said it would require people to refactor their code which might prevent wider adoption of the new exception.

Change scope of NotImplementedError

This would require the least amount of changes possible (only a documentation change) and I believe there would be no compatibility problems whatsoever.


Files

not-implemented-error-docs.patch (1.57 KB) not-implemented-error-docs.patch zdennis (Zach Dennis), 10/02/2023 01:12 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like1Like1Like0Like0Like0Like0Like0Like0Like0Like0Like1Like0Like0