[ruby-core:113189] [Ruby master Feature#19590] Include the invalid argument in error messages from `Process.clock_gettime` and `Process.clock_getres`

Issue #19590 has been reported by nobu (Nobuyoshi Nakada). ---------------------------------------- Feature #19590: Include the invalid argument in error messages from `Process.clock_gettime` and `Process.clock_getres` https://bugs.ruby-lang.org/issues/19590 * Author: nobu (Nobuyoshi Nakada) * Status: Open * Priority: Normal ---------------------------------------- The argument of `Process.clock_gettime` and `Process.clock_getres` is complex a little, it supports `Integer` and `Symbol` which are platform dependent. In most cases, available clocks are defined as constants under `Process`, but on some platforms (MinGW at least) some constants are defined but fails with `EINVAL`, and the exception doesn't tell what was wrong. ```shell-session $ ./ruby --disable=gems -v -e 'Process.constants.grep(/\ACLOCK_/).each {|c| clk = Process.const_get(c); p [c, clk, (Process.clock_gettime(clk) rescue $!)]}' ruby 3.3.0dev (2023-02-23T18:13:13Z master 1fdaa06660) [x64-mingw-ucrt] [:CLOCK_REALTIME_COARSE, 4, #<Errno::EINVAL: Invalid argument - clock_gettime>] [:CLOCK_REALTIME, 0, 1681206710.103821] [:CLOCK_MONOTONIC, 1, 167731.5111065] [:CLOCK_PROCESS_CPUTIME_ID, 2, #<Errno::EINVAL: Invalid argument - clock_gettime>] [:CLOCK_THREAD_CPUTIME_ID, 3, #<Errno::EINVAL: Invalid argument - clock_gettime>] ``` And it wastes time when passing a `Symbol` with typo. So my proposal is to add the argument to the exception message. ```shell-session $ ./miniruby -e 'p Process.clock_gettime(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME)' -e:1:in `clock_gettime': Invalid argument - clock_gettime(:CLOCK_BASED_CLOCK_PROCESS_CPUTIME) (Errno::EINVAL) from -e:1:in `<main>' ``` -- https://bugs.ruby-lang.org/
participants (1)
-
nobu (Nobuyoshi Nakada)