|
-
October 29th, 2010, 03:35 PM
#13
Re: Does error checking make code look ungly?
I generally only export C-style functions from a dll and never classes.
I also never throw exceptions on the dll level and the functions only ever return error codes.
Actually I do throw exceptions within the dll but these exceptions are caught from within and never cross the function boundary (so the consuming app doesn't need to catch any exceptions thrown by the dll).
For error passing, I usually adopt the COM error approach so each dll function returns an HRESULT.
That's what I do on the dll side of things.
On the app side of things, I like to deal with exceptions because I feel it makes the code easier to read, and error conditions are more easily cleaned up. I follow a C++ style of programming where cleanup is performed in destructors.
When I call the dll, I usually create a wrapper class that takes the dll HRESULTS and turns them into exceptions. Since the wrapper class and exceptions are defined on the app level, I get to control all of these from within the app.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|