[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] Patch: HTMLEditorKit partial implementation
From: |
Mark Wielaard |
Subject: |
Re: [cp-patches] Patch: HTMLEditorKit partial implementation |
Date: |
Tue, 13 Dec 2005 23:19:44 +0100 |
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