[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Conditional test : going crazy

user@domain.invalid

9/5/2006 9:19:00 AM

Hello, I'm goind crazy with this piece of code

response = @http.get(url, headers)
raise "url #{url} unreachable on host #{@host}:#{@port} - code
#{response.code}" if response.code != 200


The exception is raised even when response.code contains 200 !!

What's wrong ?

Thanks
4 Answers

user@domain.invalid

9/5/2006 9:21:00 AM

0

le 05/09/2006 11:18, Zouplaz nous a dit:
> Hello, I'm goind crazy with this piece of code
>
> response = @http.get(url, headers)
> raise "url #{url} unreachable on host #{@host}:#{@port} - code
> #{response.code}" if response.code != 200
>

'200' !!!!!!!!!!!!!!!!!!!!

Alex Young

9/5/2006 9:30:00 AM

0

Zouplaz wrote:
> Hello, I'm goind crazy with this piece of code
>
> response = @http.get(url, headers)
> raise "url #{url} unreachable on host #{@host}:#{@port} - code
> #{response.code}" if response.code != 200
>
>
> The exception is raised even when response.code contains 200 !!
>
> What's wrong ?
The response code isn't a number, it's a string. Try:

... if response.code != "200"

--
Alex

Stefan Lang

9/5/2006 11:50:00 AM

0


On Tuesday, September 05, 2006, at 6:29 PM, Alex Young wrote:
>Zouplaz wrote:
>> Hello, I'm goind crazy with this piece of code
>>
>> response = @http.get(url, headers)
>> raise "url #{url} unreachable on host #{@host}:#{@port} - code
>> #{response.code}" if response.code != 200
>>
>>
>> The exception is raised even when response.code contains 200 !!
>>
>> What's wrong ?
>The response code isn't a number, it's a string. Try:
>
>... if response.code != "200"
>
>--
>Alex
>

might as well do this while you are at it...

raise "url #{url} unreachable on host #{@host}:#{@port} - code
#{response.code}" unless response.code == '200'

_Kevin
www.sciwerks.com

--
Posted with http://De.... Sign up and save your mailbox.

Kurt Busiek

9/22/2009 7:13:00 PM

0

On 2009-09-22 11:15:28 -0700, Matt Hughes <archonate@googlemail.com> said:

> On 21 Sep, 23:47, Kurt Busiek <k...@busiek.com> wrote:
>
>> I look forward to reading it.
>
> And perhaps post a review?

Anything's possible!

My energy levels have been low enough of late that I've been doing
little structured writing other than that required for work (and not
enough of that), but hopefully that'll change...

kdb
--
Visit http://www.... -- for all your Busiek needs!