Hacker News new | ask | show | jobs
by turc1656 3126 days ago
"ERROR: Task completed successfully"
2 comments

This is actually really common. I can't remember if it's Linux or Windows specific, but it is almost always caused by code like this:

    result = some_system_call(argv);
    if (result == ERROR) {
        do_something_else();
        error_message = get_text_for_last_error();
        display("ERROR: " + error_message);
    }
What happens is that the call to `do_something_else()` calls another system call, which completes successfully. Unfortunately, system calls just return a success or failure code, and store the actual detailed error number in a shared global variable. So, when the handler code goes to retrieve the text message describing the error, it ends up looking up the code for the status of the second system call. But when that returned it saved the code for 'Task completed successfully' over the first error code the developer actually wanted...

I think it's probably Windows, maybe the `perror()` call, that does this?

you got my vote for funniest here so far :)