ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "Dan0042 (Daniel DeLorme) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "Dan0042 (Daniel DeLorme)" <noreply@ruby-lang.org>
Subject: [ruby-core:117604] [Ruby master Feature#18915] New error class: NotImplementedYetError or scope change for NotImplementedError
Date: Fri, 19 Apr 2024 01:39:50 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-108013.20240419013950.14023@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-18915.20220714133951.14023@ruby-lang.org

Issue #18915 has been updated by Dan0042 (Daniel DeLorme).


It's a bit off-topic but does anyone know why NotImplementedError doesn't inherit from StandardError? It seems like it should. If the system doesn't support `fork()` then I'd like to see that as a nice message via Rack::ShowExceptions rather than having to dig through logs.
And if you use it for abstract classes then you *definitely* want that displayed by Rack::ShowExceptions

----------------------------------------
Feature #18915: New error class: NotImplementedYetError or scope change for NotImplementedError
https://bugs.ruby-lang.org/issues/18915#change-108013

* Author: Quintasan (Michał Zając)
* Status: Open
----------------------------------------
# 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:

* https://github.com/rubocop/ruby-style-guide/issues/458
* http://chrisstump.online/2016/03/23/stop-abusing-notimplementederror/
* https://oleg0potapov.medium.com/ruby-notimplementederror-dont-use-it-dff1fd7228e5
* https://gitlab.com/gitlab-org/gitlab/-/issues/354314 (which I'm the author of)
* https://github.com/rmosolgo/graphql-ruby/issues/2067 (here the author actually confused it with Python's `NotImplementedError`)
* https://stackoverflow.com/questions/13668068/how-to-signal-not-implemented-yet

# 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)


-- 
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/

  parent reply	other threads:[~2024-04-19  1:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14 13:39 [ruby-core:109207] [Ruby master Feature#18915] New error class: NotImplementedYetError or scope change for NotImplementedYet Quintasan
2022-11-15 22:14 ` [ruby-core:110770] [Ruby master Feature#18915] New error class: NotImplementedYetError or scope change for NotImplementedError austin (Austin Ziegler)
2023-10-02 12:51 ` [ruby-core:114937] " zdennis (Zach Dennis) via ruby-core
2023-10-02 13:12 ` [ruby-core:114938] " zdennis (Zach Dennis) via ruby-core
2023-10-02 15:00   ` [ruby-core:114941] " Алдан Муханов via ruby-core
2023-10-13 16:19 ` [ruby-core:115043] " tenderlovemaking (Aaron Patterson) via ruby-core
2023-10-13 16:32 ` [ruby-core:115045] " Quintasan via ruby-core
2023-10-13 17:06 ` [ruby-core:115046] " byroot (Jean Boussier) via ruby-core
2023-10-13 18:27 ` [ruby-core:115048] " tenderlovemaking (Aaron Patterson) via ruby-core
2023-10-13 18:35 ` [ruby-core:115049] " byroot (Jean Boussier) via ruby-core
2023-11-08  0:37 ` [ruby-core:115297] " mame (Yusuke Endoh) via ruby-core
2023-12-20  7:17 ` [ruby-core:115804] " matz (Yukihiro Matsumoto) via ruby-core
2023-12-20  8:47 ` [ruby-core:115814] " Quintasan via ruby-core
2023-12-22 15:02 ` [ruby-core:115861] " Dan0042 (Daniel DeLorme) via ruby-core
2023-12-22 15:28 ` [ruby-core:115862] " byroot (Jean Boussier) via ruby-core
2024-04-10  3:34 ` [ruby-core:117484] " nithinbekal (Nithin Bekal) via ruby-core
2024-04-19  1:39 ` Dan0042 (Daniel DeLorme) via ruby-core [this message]
2024-04-28  0:01 ` [ruby-core:117734] " Quintasan via ruby-core

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-108013.20240419013950.14023@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    --cc=noreply@ruby-lang.org \
    --cc=ruby-core@ml.ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).