Skip to content

Commit

Permalink
check for different strings in exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
darkv committed Feb 26, 2014
1 parent a7593e5 commit 7a43065
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,15 @@
* exception when a toOne relationship object is not found in the database and adds
* debugging abilities to tracking down when faults are fired. It also supports a cache for
* array fault that is checked before they are fetched from the database.
*
* @property er.extensions.ERXDatabaseContextDelegate.Exceptions.regex regular expression to
* check the exception test for if database connection should be reopened
*/
public class ERXDatabaseContextDelegate {

public static final String DatabaseContextFailedToFetchObject = "DatabaseContextFailedToFetchObject";
public static final String ERX_ADAPTOR_EXCEPTIONS_REGEX = "er.extensions.ERXDatabaseContextDelegate.Exceptions.regex";
public static final String ERX_ADAPTOR_EXCEPTIONS_REGEX_DEFAULT = ".*_obtainOpenChannel.*|.*Closed Connection.*|.*No more data to read from socket.*";

public static class ObjectNotAvailableException extends EOObjectNotAvailableException {
/**
Expand Down Expand Up @@ -191,7 +196,8 @@ public boolean databaseContextShouldHandleDatabaseException(EODatabaseContext da
databaseContext.rollbackChanges();
throw e;
}
if(!handled && throwable.getMessage() != null && throwable.getMessage().indexOf("_obtainOpenChannel") != -1) {
String exceptionsRegex = ERXProperties.stringForKeyWithDefault(ERX_ADAPTOR_EXCEPTIONS_REGEX, ERX_ADAPTOR_EXCEPTIONS_REGEX_DEFAULT);
if(!handled && throwable.getMessage() != null && exceptionsRegex.matches(throwable.getMessage())) {
NSArray models = databaseContext.database().models();
for(Enumeration e = models.objectEnumerator(); e.hasMoreElements(); ) {
EOModel model = (EOModel)e.nextElement();
Expand Down

0 comments on commit 7a43065

Please sign in to comment.