--- parser3/src/classes/table.C 2001/10/09 13:17:45 1.124 +++ parser3/src/classes/table.C 2001/10/23 14:43:44 1.128 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: table.C,v 1.124 2001/10/09 13:17:45 parser Exp $ + $Id: table.C,v 1.128 2001/10/23 14:43:44 parser Exp $ */ #include "classes.h" @@ -80,11 +80,11 @@ static void _set(Request& r, const Strin static void _load(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); // filename is last parameter - Value& vfilename=params->as_no_junction(params->size()-1, + Value& vfile_name=params->as_no_junction(params->size()-1, "file name must not be code"); // loading text - char *data=file_read_text(pool, r.absolute(vfilename.as_string())); + char *data=file_read_text(pool, r.absolute(vfile_name.as_string())); // parse columns Array *columns; @@ -131,7 +131,7 @@ static void _load(Request& r, const Stri static void _save(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); - Value& vtable_name=params->as_no_junction(params->size()-1, + Value& vfile_name=params->as_no_junction(params->size()-1, "file name must not be code"); Table& table=static_cast(r.self)->table(); @@ -173,7 +173,7 @@ static void _save(Request& r, const Stri } // write - file_write(pool, r.absolute(vtable_name.as_string()), + file_write(pool, r.absolute(vfile_name.as_string()), sdata.cstr(), sdata.size(), true); } @@ -244,7 +244,7 @@ static void table_row_to_hash(Array::Ite if(ri.key_fieldsize(); i++) { int value_field=ri.value_fields->get_int(i); if(value_fieldas_no_junction(0, "table ref must not be code").get_table(); if(!maybe_src) - PTHROW(0, 0, + throw Exception(0, 0, &method_name, "source is not a table"); Table& src=*maybe_src; Table& dest=static_cast(r.self)->table(); if(&src == &dest) - PTHROW(0, 0, + throw Exception(0, 0, &method_name, "source and destination are same table"); @@ -496,7 +496,7 @@ static void _sql(Request& r, const Strin Pool& pool=r.pool(); if(!r.connection) - PTHROW(0, 0, + throw Exception(0, 0, &method_name, "without connect"); @@ -507,13 +507,13 @@ static void _sql(Request& r, const Strin if(params->size()>1) { Value& voptions=params->as_no_junction(1, "options must be hash, not code"); if(voptions.is_defined()) - if(Hash *options=voptions.get_hash()) { + if(Hash *options=voptions.get_hash(&method_name)) { if(Value *vlimit=(Value *)options->get(*sql_limit_name)) limit=(ulong)r.process(*vlimit).as_double(); if(Value *voffset=(Value *)options->get(*sql_offset_name)) offset=(ulong)r.process(*voffset).as_double(); } else - PTHROW(0, 0, + throw Exception(0, 0, &method_name, "options must be hash"); } @@ -524,20 +524,16 @@ static void _sql(Request& r, const Strin statement_string.cstr(String::UL_UNSPECIFIED, r.connection); Table_sql_event_handlers handlers(pool, method_name, statement_string, statement_cstr); - bool need_rethrow=false; Exception rethrow_me; - PTRY { + try { r.connection->query( statement_cstr, offset, limit, handlers); + } catch(const Exception& e) { // query problem + // more specific source [were url] + throw Exception(e.type(), e.code(), + &statement_string, + "%s", e.comment()); } - PCATCH(e) { // query problem - rethrow_me=e; need_rethrow=true; - } - PEND_CATCH - if(need_rethrow) - PTHROW(rethrow_me.type(), rethrow_me.code(), - &statement_string, // setting more specific source [were url] - rethrow_me.comment()); Table *result= handlers.table?handlers.table: // query resulted in table? return it