try doesn't handle the error??
[1/5] from: tmoeller:fastmail:fm at: 11-Oct-2010 10:28
Hi,
i got a small peace of code to be handled via try functionality:
url: http://localhost:9998
if error? err: try [
result: read/custom url [ GET ]
][
disarm err
print err/id
]
This should just print the id of the err object.
But, when i have for example a wrong url or a wrong port it doesn't seem
to get through to the handler block.
It returns:
** Access Error: Cannot connect to localhost
** Where: open-proto
** Near: result: read/custom url [GET]
>>
What am i doing wrong??
Thorsten
--
http://www.fastmail.fm - Send your email first class
[2/5] from: luca:truffarelli:it at: 11-Oct-2010 10:45
You need to reassign err:
err: disarm err
Thorsten Moeller wrote:
[3/5] from: tmoeller:fastmail:fm at: 11-Oct-2010 12:36
Hi Luca,
yes thats it. Don't really know how i could have missed this.
Thanks
Thorsten
On Mon, 11 Oct 2010 10:45 +0200, "Luca Truffarelli"
<luca-truffarelli.it> wrote:
> You need to reassign err:
> err: disarm err
<<quoted lines omitted: 29>>
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
--
http://www.fastmail.fm - Accessible with your email software
or over the web
[4/5] from: tim-johnsons:web at: 11-Oct-2010 13:08
Hello Thorsten:
I recommend you follow along with your rebol console:
Open your console and do this:
>> help disarm
USAGE:
DISARM error
DESCRIPTION:
Returns the error value as an object.
DISARM is a native value.
ARGUMENTS:
error -- (Type: error)
* Thorsten Moeller <tmoeller-fastmail.fm> [101011 01:36]:
> Hi,
> i got a small peace of code to be handled via try functionality:
<<quoted lines omitted: 5>>
> print err/id
> ]
Here's what I did:
>> if error? err: try [ result: read/custom url [ GET ]][ err: disarm err ]
;; note that I reset 'err as a return value --------------^
connecting to: localhost
>> type? err
== object!
>> probe err
make object! [
code: 507
type: 'access
id: 'no-connect
arg1: "localhost"
arg2: none
arg3: none
near: [result: read/custom url [GET]]
where: 'open-proto
]
I hope this helps and that you get my reply before the list does :)
regards
--
Tim
tim at johnsons-web.com or akwebsoft.com
http://www.akwebsoft.com
[5/5] from: tim-johnsons:web at: 11-Oct-2010 13:22
* Thorsten Moeller <tmoeller-fastmail.fm> [101011 02:52]:
> Hi Luca,
>
> yes thats it. Don't really know how i could have missed this.
Looks like you got some help that arrived between the time I sent
my message and it arrived. Just wanted to add that some programming
language distinguishes between *destructive* and *non-destructive*
functions.
Example:
In rebol 'clear would be a *destructive* function
>> t: [1 3 4 5]
== [1 3 4 5]
>> clear t
== []
>> t
== []
whereas 'disarm is a *non-destructive* function. Thus the
necessity of the reassignment.
cheers
--
Tim
tim at johnsons-web.com or akwebsoft.com
http://www.akwebsoft.com
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted