From: <leg...@at...> - 2003-10-25 11:23:56
|
The following comment has been added to this issue: Author: Max Rydahl Andersen Created: Sat, 25 Oct 2003 6:22 AM Body: well - it's not an easy call ;) I'm inclined to say that if you want to do automatically "unwrapping" then it is much safer and sound to only do it on specific exceptions instead of relying on some .equals() relation between two exceptions! So, we'll keep it as it is (unless you got a better argument ;) --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-424 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-424 Summary: Exception wrappers should not add a message Type: Patch Status: Unassigned Priority: Minor Project: Hibernate2 Components: core Versions: 2.1 beta 4 Assignee: Reporter: John Kristian Created: Thu, 23 Oct 2003 7:39 PM Updated: Thu, 23 Oct 2003 7:40 PM Description: The attached patch would be an improvement, from my point of view. Exception classes that merely wrap another exception should not add anything to the message. One reason is to simplify the implementation of code like this, which aims to remove such wrappers: if (t instanceof Nestable || t instanceof InvocationTargetException || t instanceof UndeclaredThrowableException) { cause = t.getCause(); if (cause != null) { String message = t.getMessage(); if (message != null && message.length() > 0 && ! message.equals(cause.getMessage())) { return t; } } } else if (t instanceof etc... Such code need not require special cases for Hibernate exceptions, if they refrain from adding to the message (as in the attached patch). --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-10-27 17:33:45
|
The following comment has been added to this issue: Author: John Kristian Created: Mon, 27 Oct 2003 11:24 AM Body: I agree it's not an easy call. And it doesn't matter much which way it works, so it's reasonable to choose the low-effort option. You all have better things to do, I'm sure. My example 'unwrap' algorithm wasn't clear, I fear. A rough translation to English would be: a Nestable is merely a wrapper if it contains a cause and no message except the message of its cause. This would apply to any HibernateException, since HibernateException implements org.apache.commons.lang.exception.Nestable. I think it's a Good Thing for classes in an inheritance hierarchy to behave consistently. In this case, it would be good for all classes that extend HibernateException to use the same convention for indicating that they are merely a wrapper. It would be better for all classes that implement Nestable to do likewise. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-424 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-424 Summary: Exception wrappers should not add a message Type: Patch Status: Unassigned Priority: Minor Project: Hibernate2 Components: core Versions: 2.1 beta 4 Assignee: Reporter: John Kristian Created: Thu, 23 Oct 2003 7:39 PM Updated: Thu, 23 Oct 2003 7:40 PM Description: The attached patch would be an improvement, from my point of view. Exception classes that merely wrap another exception should not add anything to the message. One reason is to simplify the implementation of code like this, which aims to remove such wrappers: if (t instanceof Nestable || t instanceof InvocationTargetException || t instanceof UndeclaredThrowableException) { cause = t.getCause(); if (cause != null) { String message = t.getMessage(); if (message != null && message.length() > 0 && ! message.equals(cause.getMessage())) { return t; } } } else if (t instanceof etc... Such code need not require special cases for Hibernate exceptions, if they refrain from adding to the message (as in the attached patch). --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-10-27 19:43:49
|
The following comment has been added to this issue: Author: Max Rydahl Andersen Created: Mon, 27 Oct 2003 1:41 PM Body: eh - HibernateException is Nestable and in JDK 1.4 ALL throwables is by default nestable...so, being Nestable (or a JDK 1.4. throwable) is not anything you can use to "detect" a wrapper exception. Similarily, you cannot just use the rule about "if the message is equals to the lower exception" to detect a wrapper....that you should use the actual type - that's the only mechanism we have available. Because then it would be a very explicit and "trackable" decision ;) ...but we won't change this in Hibernate since NOT adding something to the message is also bad since it makes it impossible to distinguish from the nested exception message - and that is worse in my book ;) --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-424 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-424 Summary: Exception wrappers should not add a message Type: Patch Status: Unassigned Priority: Minor Project: Hibernate2 Components: core Versions: 2.1 beta 4 Assignee: Reporter: John Kristian Created: Thu, 23 Oct 2003 7:39 PM Updated: Thu, 23 Oct 2003 7:40 PM Description: The attached patch would be an improvement, from my point of view. Exception classes that merely wrap another exception should not add anything to the message. One reason is to simplify the implementation of code like this, which aims to remove such wrappers: if (t instanceof Nestable || t instanceof InvocationTargetException || t instanceof UndeclaredThrowableException) { cause = t.getCause(); if (cause != null) { String message = t.getMessage(); if (message != null && message.length() > 0 && ! message.equals(cause.getMessage())) { return t; } } } else if (t instanceof etc... Such code need not require special cases for Hibernate exceptions, if they refrain from adding to the message (as in the attached patch). --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |
From: <leg...@at...> - 2003-10-27 20:22:34
|
The following comment has been added to this issue: Author: John Kristian Created: Mon, 27 Oct 2003 2:19 PM Body: It's OK with me that Hibernate won't change. I already have code that works around it; it wasn't hard to write and I don't expect it will be hard to maintain. Let's go work on something else that matters more. But I can't resist these parting shots: No, java.lang.Throwable doesn't implement org.apache.commons.lang.exception.Nestable. It's true that 'instanceof Nestable' is not a reliable factor for deciding whether an exception is a wrapper. But that's a bug, from my point of view. Higher-level code needs to remove wrappers. It would be better if the wrappers helped with this. One can tell whether the exception occurred in a callback or validator by looking at the wrapper class and/or stack trace. That's enough for me; I don't feel a need to repeat the same fact in the message. I prefer a message that's meaningful and interesting to an end user or high level caller. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-424 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-424 Summary: Exception wrappers should not add a message Type: Patch Status: Unassigned Priority: Minor Project: Hibernate2 Components: core Versions: 2.1 beta 4 Assignee: Reporter: John Kristian Created: Thu, 23 Oct 2003 7:39 PM Updated: Thu, 23 Oct 2003 7:40 PM Description: The attached patch would be an improvement, from my point of view. Exception classes that merely wrap another exception should not add anything to the message. One reason is to simplify the implementation of code like this, which aims to remove such wrappers: if (t instanceof Nestable || t instanceof InvocationTargetException || t instanceof UndeclaredThrowableException) { cause = t.getCause(); if (cause != null) { String message = t.getMessage(); if (message != null && message.length() > 0 && ! message.equals(cause.getMessage())) { return t; } } } else if (t instanceof etc... Such code need not require special cases for Hibernate exceptions, if they refrain from adding to the message (as in the attached patch). --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |