Is it possible for me to create my own error codes? Such as if a function fails to accomplish it's task an error handler activates? I was thinking something like this, althought theoretically it sounds good for me, I'm not sure it would actually work;
But in that case if my "myFunction()" had an error it would have to return a false bool. But the program would crash before it did that. How could I solve this?
If a function crashes the program, there's nothing to do other than fix the function. The purpose of an error code is to give information about the result of a call under normal operation. For example, function that loads and displays a JPEG file on the screen could return NO_ERROR, FILE_NOT_FOUND, NOT_A_JPEG, BROKEN_FILE, etc. None of these are crashing conditions. The function is supposed to check the validity of the file.
For example, I was trying to work on an ecryption program. When I compile it, no compiling errors occur. Despite the misfunctionality of the proper encryption (in other words, ignore it), when it comes to writing the "encrypted" string to a file it gives me a weird run-time error. Kind of the error that happens when you try to allocate to much memory. In this case you have the &bad_alloc but in my run-time errors I don't. So what did I try? To make an error handler based on boolean values. I already deleted the source code of the program since it simply didn't work (damn, I screwed on that one). But in any general case, when a runtime error occures, can't I fix it with boolean values?
I don't get it. "Fix" it? With bools? I'm just not following.
In any case, it sounds like you had some serious bugs, there. A buffer overflow has nothing to do with error or exception handling. That's something you have to fix yourself.
Ok, I think I exaplained myself badly in my last post. I don't want to fix the FILE_NOT_FOUND, but how could I define it? I mean, the compiler won't assume itself that FILE_NOT_FOUND refers to that the file the person asked for doesn't exist.