jg_at_pharos
jg_at_pharos

Reputation: 81

How can I robustly pass errors to client code without using enums?

I'm writing a system that can, and will, be extended by client code. It needs to be capable of reporting errors in its configuration. Having an enum defining error codes won't work, because subclasses in client code may return entirely new error codes. And besides, it becomes a compilation bottleneck.

Returning an error as a message string isn't brilliant either, because there may be a need to localize the text.

I am tempted to return the error code as a string (and pray for uniqueness) but that sounds wasteful. Is there a pattern that solves this sort of problem?

Upvotes: -1

Views: 62

Answers (0)

Related Questions