Created
March 27, 2014 17:28
-
-
Save mgroves/9813179 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public override void OnInvoke(MethodInterceptionArgs args) | |
| { | |
| try | |
| { | |
| args.Proceed(); | |
| } | |
| catch (SqlException ex) | |
| { | |
| ex.ToExceptionless().Submit(); | |
| var obj = (ServiceBase) args.Instance; | |
| if (ex.Message.Contains("The DELETE statement conflicted with the REFERENCE constraint")) | |
| obj.AddValidationError("This item can't be deleted because it is still used by other items."); | |
| else | |
| obj.AddValidationError("There was a database error. Please try again later. (" + ex.Message + "), (" + | |
| ex.GetType().FullName + ")"); | |
| } | |
| catch (NotImplementedException) | |
| { | |
| // if something's not implemented, just throw it up | |
| throw; | |
| } | |
| catch (Exception ex) | |
| { | |
| ex.ToExceptionless().Submit(); | |
| var obj = (ServiceBase)args.Instance; | |
| obj.AddValidationError("There was an error. Please try again later. (" + ex.Message + "), (" + ex.GetType().Name + ")"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment