Skip to content

C++ debug: extend natvis to allow it to display the message() of std::error_code #242514

Closed
@StephenApptronik

Description

@StephenApptronik

The type "std::error_code" is part of the standard library for communicating errors when not using exceptions in C++. When an error is set, it constructs an object that is an integer and a reference to an object that can translate that integer into a string. However, the Watch window by default displays errors like this:

err = std::error_code = {std::_V2::error_category: 2}

To get the message string, one has to invoke err.message(). For an error type on the stack, I can do that, although it is annoying that I cannot simply add a watch to err or get that info through hover. When the error is embedded in a cluster of more information, it gets harder.

Currently natvis cannot be taught how to display the message because that involves invoking a function. Is there any way to add the view functionality for err specifically without opening up the full can of worms that is arbitrary function invocation?

Metadata

Metadata

Assignees

Labels

*caused-by-extensionIssue identified to be caused by an extension

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions