|
|
Line 140: |
Line 140: |
|
| |
|
| === Savegames === | | === Savegames === |
| * Added error return codes to openForSaving / openForLoading so that client code can nicely detect & report save/load failures ("media full", "file not found", "save path does not exist", "save path not writeable", etc.).
| |
| * Try to get rid of getSavePath(): It is mostly used to print out more meaningful error messages about save failures. Instead of that, consider adding a getLastError() or so call, which return a string with additional information about the error. This is more portable, too.
| |
| * <p>Let me give a specific example on how error handling could look like:
| |
| <pre>
| |
| ErrorCode err = saveMan->openForSaving(name, &myFile);
| |
| if (!err) {
| |
| myFile->write(...);
| |
| ...
| |
| err = myFile->ioError();
| |
| }
| |
| switch (err) {
| |
| case kNoError:
| |
| break;
| |
| case kMediaFullError:
| |
| display("Writing your save game failed due to lack of space: %s", saveMan->getErrorString());
| |
| default:
| |
| display("An error occured while writing a savegame: %s", saveMan->getErrorString());
| |
| }
| |
| </pre>
| |
| As a slight variation, we could introduce an "error manager" which offers the "getErrorString" method and which could be used by more code. Compare also with SDL_SetError & SDL_GetError.
| |
| </p>
| |
|
| |
|
| == Engines / frontends == | | == Engines / frontends == |