Click here to Skip to main content
15,881,852 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Driver development help & tips Pin
Erudite_Eric20-May-12 23:02
Erudite_Eric20-May-12 23:02 
QuestionBest way to handle errors (esp. in games) Pin
forkbomber18-May-12 11:15
forkbomber18-May-12 11:15 
AnswerRe: Best way to handle errors (esp. in games) Pin
TomasRiker218-May-12 13:23
TomasRiker218-May-12 13:23 
GeneralRe: Best way to handle errors (esp. in games) Pin
Stefan_Lang21-May-12 23:54
Stefan_Lang21-May-12 23:54 
AnswerRe: Best way to handle errors (esp. in games) Pin
David Crow18-May-12 16:19
David Crow18-May-12 16:19 
GeneralRe: Best way to handle errors (esp. in games) Pin
charlieg21-May-12 5:50
charlieg21-May-12 5:50 
GeneralRe: Best way to handle errors (esp. in games) Pin
David Crow21-May-12 5:59
David Crow21-May-12 5:59 
AnswerRe: Best way to handle errors (esp. in games) Pin
Aescleal18-May-12 22:39
Aescleal18-May-12 22:39 
Use exceptions for errors you can't recover from e.g:

- Wrong OpenGL version, throw an exception
- No memory - runtime throws an exception for you
- Can't find a critical game resource, a fall back texture, shader or something else that really must be there
- Some muppet's deleted a delay loaded DLL
- Steam doesn't initialise and you're using it for copy protection
- You can't open any file to save the game - throw an exception

Use return values for things you can recover from, e.g:

- Network connection flakey - you don't want your game to crash 'cause your cheap hosting server in Borneo is offline due to Orang-utan attack
- Can't find a game resource that you have a fallback for
- Steam can't share a file, back off and try again
- You can't open a save game file, back off and try again with a different name

If you're code looks ugly you're not using exceptions for critical errors and you've got exception handlers all over the place.

Ideally for yummy, perfect code you should only have exception handlers:

- At the top level of your code - around main, WinMain or whatever for your platform
- Around thread entry/exit functions
- Around window procedures/GUI callbacks

So basically:

- Exceptions are for critical errors
- Exception handlers only appear when your code is about to disapear UP the call stack into the OS, otherwise madness and the end of western civilisation will result.

Exceptions being really expensive is a myth. See one of the previous posts for details, or hey, measure it yourself.
GeneralRe: Best way to handle errors (esp. in games) Pin
forkbomber18-May-12 23:34
forkbomber18-May-12 23:34 
AnswerRe: Best way to handle errors (esp. in games) Pin
Stefan_Lang22-May-12 0:12
Stefan_Lang22-May-12 0:12 
QuestionUnable to write into Shared memory Pin
manoharbalu18-May-12 1:26
manoharbalu18-May-12 1:26 
AnswerRe: Unable to write into Shared memory Pin
TomasRiker218-May-12 2:27
TomasRiker218-May-12 2:27 
GeneralRe: Unable to write into Shared memory Pin
zhaolei.cpp@gmail.com18-May-12 3:53
zhaolei.cpp@gmail.com18-May-12 3:53 
GeneralRe: Unable to write into Shared memory Pin
zhaolei.cpp@gmail.com18-May-12 4:05
zhaolei.cpp@gmail.com18-May-12 4:05 
QuestionGetItemDataPtr (ComboBox) Not Working For Me Pin
AmbiguousName18-May-12 1:13
AmbiguousName18-May-12 1:13 
AnswerRe: GetItemDataPtr (ComboBox) Not Working For Me Pin
TomasRiker218-May-12 2:29
TomasRiker218-May-12 2:29 
GeneralRe: GetItemDataPtr (ComboBox) Not Working For Me Pin
zhaolei.cpp@gmail.com18-May-12 4:09
zhaolei.cpp@gmail.com18-May-12 4:09 
QuestionRe: GetItemDataPtr (ComboBox) Not Working For Me Pin
David Crow18-May-12 2:35
David Crow18-May-12 2:35 
AnswerRe: GetItemDataPtr (ComboBox) Not Working For Me Pin
AmbiguousName18-May-12 3:42
AmbiguousName18-May-12 3:42 
AnswerRe: GetItemDataPtr (ComboBox) Not Working For Me Pin
David Crow18-May-12 4:59
David Crow18-May-12 4:59 
AnswerRe: GetItemDataPtr (ComboBox) Not Working For Me Pin
Luc Pattyn18-May-12 5:24
sitebuilderLuc Pattyn18-May-12 5:24 
QuestionReference a struct member variable Pin
manoharbalu17-May-12 0:47
manoharbalu17-May-12 0:47 
AnswerRe: Reference a struct member variable Pin
Chris Losinger17-May-12 1:33
professionalChris Losinger17-May-12 1:33 
AnswerRe: Reference a struct member variable Pin
CPallini17-May-12 1:49
mveCPallini17-May-12 1:49 
AnswerRe: Reference a struct member variable Pin
Richard MacCutchan17-May-12 2:54
mveRichard MacCutchan17-May-12 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.