Skip to content

Commit

Permalink
ERXEOAccessUtilities.isUniqueFailure Check added
Browse files Browse the repository at this point in the history
  • Loading branch information
ishimoto authored and Pascal Robert committed Jul 23, 2012
1 parent 5f037d5 commit e33b081
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,29 @@ public static boolean isOptimisticLockingFailure(EOGeneralAdaptorException e) {
return wasHandled;
}

/**
* <span class="ja">
* 例外エラーが重複エラーの場合は true を戻します。
*
* @param e - saveChanges() から受けた例外エラーそのまま
*
* @return エラーが処理できた場合は true
* </span>
*/
public static boolean isUniqueFailure(EOGeneralAdaptorException e) {
boolean wasHandled = false;
NSDictionary userInfo = e.userInfo();
if(userInfo != null) {
EOAdaptorOperation adaptorOp = (EOAdaptorOperation) userInfo.objectForKey(EOAdaptorChannel.FailedAdaptorOperationKey);

wasHandled = adaptorOp.toString().contains("UNIQUE");
if (!wasHandled) {
log.error("UNIQUE Integrity constraint violation " + e + ": " + userInfo);
}
}
return wasHandled;
}

/**
* Given an array of EOs, returns snapshot dictionaries for the given
* related objects.
Expand Down

0 comments on commit e33b081

Please sign in to comment.