all repos — mgba @ d662ba98de41c22489ca4d42ae3291fe043aa13e

mGBA Game Boy Advance Emulator

OpenEmu: Use error handling outputs
Jeffrey Pfau jeffrey@endrift.com
Sat, 02 Jan 2016 16:39:27 -0800
commit

d662ba98de41c22489ca4d42ae3291fe043aa13e

parent

c2340bb44fb89e4a4c95bcf62a826c28059daeda

1 files changed, 11 insertions(+), 6 deletions(-)

jump to
M src/platform/openemu/mGBAGameCore.msrc/platform/openemu/mGBAGameCore.m

@@ -93,10 +93,7 @@ #pragma mark - Execution

- (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error { - UNUSED(error); - NSString *batterySavesDirectory = [self batterySavesDirectoryPath]; - NSLog(batterySavesDirectory); [[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:batterySavesDirectory] withIntermediateDirectories:YES attributes:nil

@@ -107,9 +104,14 @@ }

context.dirs.save = VDirOpen([batterySavesDirectory UTF8String]); if (!GBAContextLoadROM(&context, [path UTF8String], true)) { + *error = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadROMError userInfo:nil]; return NO; } - GBAContextStart(&context); + + if (!GBAContextStart(&context)) { + *error = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotStartCoreError userInfo:nil]; + return NO; + } return YES; }

@@ -213,10 +215,13 @@ }

- (BOOL)deserializeState:(NSData *)state withError:(NSError **)outError { - UNUSED(outError); // TODO VFileFromConstMemory struct VFile* vf = VFileFromMemory((void*) state.bytes, state.length); - return GBALoadStateNamed(context.gba, vf, 0); + if (!GBALoadStateNamed(context.gba, vf, 0)) { + *outError = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadStateError userInfo:nil]; + return NO; + } + return YES; } - (void)saveStateToFileAtPath:(NSString *)fileName completionHandler:(void (^)(BOOL, NSError *))block