W3C home > Mailing lists > Public > public-mobileok-checker@w3.org > January 2008

Exceptions thrown by the mobileok checker

From: Francois Daoust <fd@w3.org>
Date: Wed, 30 Jan 2008 15:12:44 +0100
To: public-mobileok-checker@w3.org
Message-Id: <1201702365.5892.114.camel@DOUST-W3CLAPTOP>


While re-writing the mobileOK checker validation page, I encountered a
few cases when the checker throws some exceptions, not because it
crashed, but because the URI entered is either inaccessible or not
valid. See examples below.

The exceptions being thrown are developer-readable, but throwing such
exceptions when it's not the checker's fault makes it harder to wrap
something around it. If you take a look at:
... one would immediately think the checker crashed, and try again, and
again, and then yell by email.
[note the exception returned is slightly different from the example
below because the version of the JAR is older]

I'll handle the exceptions I can think of in the validator page to
return a more user-friendly message that really states that the problem
lies with the URI, but I tend to think the checker should be a black box
that only throws exceptions when it crashes because of a bug, not
because the URI is incorrect, and thus that the catching should rather
be done within the checker.

Or that we should at least provide the list of the exceptions that may
be thrown by the checker [does it already exist?]

I don't think that needs to be done for the beta though...
If there's no objection, I could also action myself and do that,
although I'm not sure I'll be able to work on it very soon.

What do you think?



1. network error because the resource cannot be accessed:
java -jar mobileOK-Basic-RI-1.0-deploy.jar thisdomaindoesntexist.com
Exception in thread "main" org.w3c.mwi.mobileok.basic.TestException: A network error has happened while retrieving the requested Web page.
MobileOK Basic Test can not be launched.
        at org.w3c.mwi.mobileok.basic.Preprocessor.preprocess(Preprocessor.java:37)
        at org.w3c.mwi.mobileok.basic.Tester.getPreprocessorResults(Tester.java:91)
        at org.w3c.mwi.mobileok.basic.Tester.main(Tester.java:201)

2. URI syntax error because the URI is invalid:
java -jar mobileOK-Basic-RI-1.0-deploy.jar http://
Exception in thread "main" java.net.URISyntaxException: Expected authority at index 7: http://
        at java.net.URI$Parser.fail(URI.java:2809)
        at java.net.URI$Parser.failExpecting(URI.java:2815)
        at java.net.URI$Parser.parseHierarchical(URI.java:3063)
        at java.net.URI$Parser.parse(URI.java:3014)
        at java.net.URI.<init>(URI.java:578)
        at org.w3c.mwi.mobileok.basic.Tester.main(Tester.java:136)

3. Protocol error when the URI is valid but the protocol unknown:
java -jar mobileOK-Basic-RI-1.0-deploy.jar invalid://something
Exception in thread "main" java.lang.IllegalStateException: unsupported protocol: 'invalid'
        at org.apache.commons.httpclient.protocol.Protocol.lazyRegisterProtocol(Protocol.java:149)
        at org.apache.commons.httpclient.protocol.Protocol.getProtocol(Protocol.java:117)
        at org.apache.commons.httpclient.HttpHost.<init>(HttpHost.java:107)
        at org.apache.commons.httpclient.HttpMethodBase.setURI(HttpMethodBase.java:280)
        at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:220)
        at org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89)
        at org.w3c.mwi.mobileok.basic.HTTPResource.<init>(HTTPResource.java:107)
        at org.w3c.mwi.mobileok.basic.HTTPResource.<init>(HTTPResource.java:80)
        at org.w3c.mwi.mobileok.basic.HTTPTextResource.<init>(HTTPTextResource.java:37)
        at org.w3c.mwi.mobileok.basic.HTTPXHTMLResource.<init>(HTTPXHTMLResource.java:93)
        at org.w3c.mwi.mobileok.basic.Preprocessor.preprocess(Preprocessor.java:31)
        at org.w3c.mwi.mobileok.basic.Tester.getPreprocessorResults(Tester.java:91)
        at org.w3c.mwi.mobileok.basic.Tester.main(Tester.java:201)
Received on Wednesday, 30 January 2008 14:12:51 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:21:19 UTC