Skip to content

Streamline exceptions #4

@nobugs-hare

Description

@nobugs-hare

IMPORTANT: before starting implementing it, we have to harmonize it with https://nodejs.org/api/errors.html

Exception Ideology:

  • everybody uses nodecpp::error - value-based, alongside P0709 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0709r0.pdf). It has member error(),

  • everybody catches it ONLY by reference (sic!)

  • API-wise, alongside P0709, nodespp::error has comparison operators, bunch of static members which represent pre-constructed standard errors (to be trhown and/or compared to), and member error() which returns const char*so that both print("{}",x.error()) is possible.

  • standard errors are NOT migrated by default into nodecpp::error, we have to define ALL the errors within nodecpp::error ourselves.

  • allocation failure IS an exception (at least for the time being).

  • implementation-wise, we want to provide TWO implementations for nodecpp::error (chosen by project-level ≠define):
    a. based on std::exception
    b. based on https://github.com/ned14/status-code (though probably based on their status_code, NOT on their error classes; in any case we MUST NOT use typedef as we need full control over API)

This will allow us to:
a. provide convenient exception semantics
b. to be future-proof in a sense that whenever P0709 is supported by compilers, end-user will be able to CHOOSE whether they want to have std::exception-based performance or value-based performance - while preserving exactly the same code (the one which we enforce from the very beginning).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions