From 32e858b26923b371a93e800687a13edf1254e445 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 25 Mar 2010 01:13:12 +0000 Subject: - Make [MCPConnection getLastErrorMessage] more consistent by always returning nil if no error occurred (previously a blank string was returned most of the time) - Add a new (BOOL)[MCPConnection queryErrored] method, changing all error message checks to use it for clarity --- Source/SPTableData.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Source/SPTableData.m') diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 2b07fbce..1807b66e 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -330,7 +330,7 @@ [theResult setReturnDataAsStrings:YES]; // Check for any errors, but only display them if a connection still exists - if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { + if ([mySQLConnection queryErrored]) { if ([mySQLConnection isConnected]) { SPBeginAlertSheet(NSLocalizedString(@"Error retrieving table information", @"error retrieving table information message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, @@ -598,7 +598,7 @@ [theResult setReturnDataAsStrings:YES]; // Check for any errors, but only display them if a connection still exists - if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { + if ([mySQLConnection queryErrored]) { if ([mySQLConnection isConnected]) { SPBeginAlertSheet(NSLocalizedString(@"Error retrieving table information", @"error retrieving table information message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, @@ -692,7 +692,7 @@ [theResult setReturnDataAsStrings:YES]; // Check for any errors, but only display them if a connection still exists - if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { + if ([mySQLConnection queryErrored]) { if ([mySQLConnection isConnected]) { SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, @@ -711,7 +711,7 @@ [theResult setReturnDataAsStrings:YES]; // Check for any errors, but only display them if a connection still exists - if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { + if ([mySQLConnection queryErrored]) { if ([mySQLConnection isConnected]) { SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, @@ -809,7 +809,7 @@ } // Check for any errors, only displaying them if the connection hasn't been terminated - if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { + if ([mySQLConnection queryErrored]) { if ([mySQLConnection isConnected]) { SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [NSApp mainWindow], self, nil, nil, nil, @@ -840,7 +840,7 @@ // this happens e.g. for db "information_schema" if([[status objectForKey:@"Rows"] isKindOfClass:[NSNull class]]) { tableStatusResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [escapedTableName backtickQuotedString] ]]; - if ([[mySQLConnection getLastErrorMessage] isEqualToString:@""]) + if (![mySQLConnection queryErrored]) [status setObject:[[tableStatusResult fetchRowAsArray] objectAtIndex:0] forKey:@"Rows"]; [status setObject:@"y" forKey:@"RowsCountAccurate"]; } @@ -1064,7 +1064,7 @@ if([r numOfRows] < 1) return nil; - if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) { + if ([mySQLConnection queryErrored]) { if ([mySQLConnection isConnected]) NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while retrieving the PRIAMRY KEY data:\n\n%@", [mySQLConnection getLastErrorMessage]], @"OK", nil, nil); return nil; -- cgit v1.2.3