Hacker News new | past | comments | ask | show | jobs | submit login

Errors as return codes are harder to clobber as a side effect. Some examples, on Windows you have HRESULT or NTSTATUS, on Mac you have osstatus. Some posix functions also return errno values, eg. pthread_create, likely due to early perceptions that errno cannot be made thread safe. (Fixed these days by making errno into a macro that resolves to a function that does thread local storage.)

Probably fans of higher level languages might prefer exceptions, but this would be inapplicable to C.

Some frameworks (glib, parts of cocoa) have a concept of "error object" which is an extra pointer to a struct parameter that can receive rich error context.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: