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

Re: Exceptions thrown by the mobileok checker

From: Guido García Bernardo <ggarciab@itdeusto.com>
Date: Wed, 30 Jan 2008 16:01:39 +0100
Message-ID: <47A09153.5070606@itdeusto.com>
To: Jo Rabin <jrabin@mtld.mobi>
CC: public-mobileok-checker@w3.org
Yes, I have had that problem with some pages that contains wrong links 
to external resources, getting exceptions like :

Exception in thread "main" java.lang.IllegalArgumentException: Invalid 
uri 
'http://prisacomas.112.2o7.net/b/ss/prisacomas/1/H.11--NS/0?[AQB]&pccr=true&g=none&[AQE]': 
Invalid query
    at 
org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:222)
    at 
org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89)
    at org.w3c.mwi.mobileok.basic.HTTPResource.<init>(Unknown Source)
    at org.w3c.mwi.mobileok.basic.HTTPImageResource.<init>(Unknown Source)
    at org.w3c.mwi.mobileok.basic.Preprocessor.preprocess(Unknown Source)
    at org.w3c.mwi.mobileok.basic.Preprocessor.preprocess(Unknown Source)
    at org.w3c.mwi.mobileok.basic.Tester.getPreprocessorResults(Unknown 
Source)
    at org.w3c.mwi.mobileok.basic.Tester.main(Unknown Source)

As Francois said, I think the catching should be done within the 
checker.  That way, an error in the page being tested does not imply a 
crash in the whole testing process.

For example, in the HTTPResource constructor, what happens when the uri 
argument is not valid ?

HTTPResource(final URI uri ...) ... {
    ...
    URI redirectURI = this.uri;
    ...
    final HttpMethod method = new GetMethod(redirectURI.toString()); // 
IllegalArgumentException
    ...
}

HttpClient throws an IllegalArgumentException that is not caugth...
Please correct me if I am missing some thing.

guido.

Jo Rabin escribió:
> Presumably the same exceptions get thrown if a page under test has an
> invalid reference to some external resource? In which case I suggest
> that we catch these exceptions before beta starts on the basis that the
> result should be FAIL.
>
> Jo
>
>
>
>   
>> -----Original Message-----
>> From: public-mobileok-checker-request@w3.org [mailto:public-mobileok-
>> checker-request@w3.org] On Behalf Of Francois Daoust
>> Sent: 30 January 2008 14:13
>> To: public-mobileok-checker@w3.org
>> Subject: Exceptions thrown by the mobileok checker
>>
>>
>> Hi,
>>
>> 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:
>> http://validator.w3.org/mobile/alpha?docAddr=test
>> ... 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?
>>
>> Francois.
>>
>>
>>
>> Examples:
>>
>> 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(Pro
> to
>   
>> col.java:149)
>>         at
>>
>>     
> org.apache.commons.httpclient.protocol.Protocol.getProtocol(Protocol.jav
> a:
>   
>> 117)
>>         at
>> org.apache.commons.httpclient.HttpHost.<init>(HttpHost.java:107)
>>         at
>>
>>     
> org.apache.commons.httpclient.HttpMethodBase.setURI(HttpMethodBase.java:
> 28
>   
>> 0)
>>         at
>>
>>     
> org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:
> 22
>   
>> 0)
>>         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
> :3
>   
>> 7)
>>         at
>>
>>     
> org.w3c.mwi.mobileok.basic.HTTPXHTMLResource.<init>(HTTPXHTMLResource.ja
> va
>   
>> :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 15:02:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2008 15:02:34 GMT