[REBOL] Error handling problems revisited
From: kpeters::otaksoft::com at: 14-Nov-2007 18:55
I cannot seem to figure it out...
Here's what I am doing:
===============
mysql-obj: attempt [ make object! load %mysql.cfg ]
mysql-url: rejoin [ mysql:// mysql-obj/user ":" mysql-obj/password "-" mysql-obj/host
":"
mysql-obj/port "/" mysql-obj/database ]
mysqlport: none
;--------------------------------------------------------------------------------------------------
mysql-query: function [ {Either returns [["ERROR"]], [["EMPTY"]] or [[<cursor>]}
querystr [string! block!] statusbar [object! none!]] [ cursor ] [
if error? set/any 'mysql-error try [
mysqlport: open mysql-url
cursor: send-sql mysqlport querystr
close mysqlport
]
[
disarm mysql-error
if statusbar <> none [ set-face statusbar reform [ "MySQL-Connection error: "
mysql-error/arg1 ]]
return [["ERROR"]]
]
if cursor = [] [ return [[ "EMPTY" ]] ]
either cursor/1/1 = none [ return [[ "EMPTY" ]] ] [ return cursor ]
]
I set the IP of my MySQL server in %mysql.cfg to a non-existent number in my network
in order to
trigger an error.
Here's what I would expect:
==================
The error we see below should get trapped in my code and the mysql-query function should
return [["ERROR"]]
Here's what I get:
============
** Access Error: Cannot connect to 192.168.1.223
** Where: open-proto
** Near: mysqlport: open mysql-url
cursor: send-sql
Why does my code not catch this?
Any help *greatly* appreciated!
Kai