Hi Lillian,
On Tue, 2005-12-13 at 11:28 -0500, Lillian Angel wrote:
> @@ -338,7 +340,14 @@
> */
> protected HTMLDocument getHTMLDocument(JEditorPane e)
> {
> - return (HTMLDocument) e.getDocument();
> + try
> + {
> + return (HTMLDocument) e.getDocument();
> + }
> + catch (Exception ex)
> + {
> + throw new IllegalArgumentException("Document is not a
> HTMLDocument.");
> + }
> }
>
> /**
> @@ -349,7 +358,15 @@
> */
> protected HTMLEditorKit getHTMLEditorKit(JEditorPane e)
> {
> - return (HTMLEditorKit) e.getEditorKit();
> + try
> + {
> + return (HTMLEditorKit) e.getEditorKit();
> + }
> + catch (Exception ex)
> + {
> + throw new IllegalArgumentException(
> + "EditorKit is not a
> HTMLEditorKit.");
> + }Try catching a more specific Exception (like ClassCastException) or first trying if (e instanceof HTMLEditor). And when catching an exception and throwing a new one it often makes sense to chain the exceptions with initCause(). Cheers, Mark
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Classpath-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/classpath-patches
