From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id BB5263858D35 for ; Mon, 16 Aug 2021 12:11:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BB5263858D35 Received: by mail-wr1-x430.google.com with SMTP id x12so23244080wrr.11 for ; Mon, 16 Aug 2021 05:11:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=MwChc9QXdc4VVzXnWTTrGAdQV3CsFicrA/oWmuq5uXw=; b=PqYJbCqeHT9mssUJxRBSwm9AP4mWEN0I6jgDV/LwFIiinJhTantwjHMGlqqKbpZkoo AS870ean43rIRic6btpJkn+wGHMj8t9C4Dg2Y8Ly6TEFz+BPd+7PPDlxaCy9UfCfooMd iUjNLoJQz5XxtMPEESi49s5K7Y+QXXSsQx/0BORe3/Hi/NRfIjpTwJ5B995ds9KHQQR0 d08OKpE6jUXXvlpUBXAD3IWatZCSuqp9puVvlEZrYBTkHpdqn06JxjCqOFvgqJQHqnaM 19n01MuZw9APNJPa8reUCI4m+LWrVxt/T9oiNHN0XO2vcT9WAJWKWOGEBaDN6cUOn/Zu ewWA== X-Gm-Message-State: AOAM531+zMPoFVAZA/g0KkHijU0DbWtJUnoDRhbCGq50H+r21cSNEKea oohW0qlbuYR8m49/M3MQiQ9BCrJcBh+XShkXb/I14gW2 X-Google-Smtp-Source: ABdhPJzmpcfMeqdZZm216oBG8IjFHvJbIn7fe9DYTcCQWJAwjJMDUsabKb0TiM4ToktrJrn53EW+7bjt/fFCRnQe0wE= X-Received: by 2002:adf:e4ce:: with SMTP id v14mr17976782wrm.21.1629115891840; Mon, 16 Aug 2021 05:11:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Mon, 16 Aug 2021 13:11:18 +0100 Message-ID: Subject: Re: What should a std::error_code pretty printer show? To: "libstdc++" X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Aug 2021 12:11:34 -0000 On Mon, 16 Aug 2021, 12:55 Jonathan Wakely, wrote: > I'm adding a GDB printer for std::error_code.What I have now prints > the category name as a quoted string, followed by the error value: > > {"system": 0} > {"system": 1234} > > If the category is std::generic_category() then it also shows the > strerror description: > I should probably extend this special case for the generic category to also apply to the system category when the OS is POSIX-based. For POSIX systems, the system error numbers are generic errno values. > {"generic": 13 "Permission denied"} > > But I'd also like it to show the errno macro, but I'm not sure what's > the best way to show it. > > Does this seem OK? > > {"generic": 13 EACCES "Permission denied"} > > I think that's a bit too verbose. > > Would {"generic": EACCES} be better? You can always use ec.value() to > get the numeric value, and strerror to get the description if you want > those. >