SanderMertens / flecs

A fast entity component system (ECS) for C & C++
https://www.flecs.dev
Other
6.46k stars 454 forks source link

Completion of error handling #15

Closed elfring closed 5 years ago

elfring commented 5 years ago

Would you like to add more error handling for return values from functions like the following?

SanderMertens commented 5 years ago

Yes, definitely. Since I have your ear, I'd like to do a more comprehensive review of error handling. Today the API asserts when there is an error, and you get the file + line where the assert happened. Often that is sort of useful, but you don't really know where the error happened in your app code.

I'd like to move the actual assert to a macro that wraps the API, so that the assert reports the location in the application code, not in the library. That could make it much easier to debug things, as I don't need another tool to obtain the stack trace to see where it happened. Additionally, if you would use the "unwrapped" API, you'd have an API that never asserts, so you kind of have the best of both worlds.

Anyway, that's just an idea I thought would make life a little bit easer. Curious to hear what people think.

elfring commented 5 years ago

How do you think about to improve static source code analysis also for this software?


SanderMertens commented 5 years ago

@elfring Ok, I will reconsider that. For now, I will stick with the current approach, and address the issues you identified.

SanderMertens commented 5 years ago

I added a more complete description of error handling here: https://github.com/SanderMertens/flecs/blob/master/Manual.md