Throw, come back or make a mistake?

I am creating a system. What I want to know if msg is not supported, what should it do? Should I throw an unsupported message? should i return 0 or -1? or should I install errno (base-> errno_). Some messages I would not care if there was an error (for example, setBorderColour). Others I would (addText or possibly save if I create save cmd).

I want to know what is the best way for 1) to code quickly 2) to debug 3) extension and maintenance. I can do 3rd debugging, it is difficult to debug ATM, but bc has a lot of missing code that I did not fill out. Actual errors are hard to fix. What is the best way to tell the user that there is an error?

The system works something like this, but not exactly the same. This is a C style, and mycode has many built-in functions that carry settext (const char * text) {to msg (this, esettext, text)

Base base2, base;
base = get_root();
base2 = msg(base, create, BASE_TYPE);
msg(base2, setText, "my text");
const char *p = (const char *)msg(base2, getText);
+3
source share
4 answers

, ++, , (, ), . , , . , . , . errno , (, , ).

, , , , , . , , , , , , , .

errno, . , , , .

: , - errno, errno. , , , ( ), .

+8

, , . , , , "" . (, , , ).

, , , , , ( Java, ). , , ( , , , ). , , , .

, , . , , , , . , , , , . , ( ).

+2

, , , . .

.

0

errno , 'C'. ++, .

It depends on how "deadly" these errors are. Does the user really need to see the error, or is it for other developer mentors?

For ease of maintenance, you need to clearly document errors that may occur and include clear examples of error handling.

0
source

All Articles