--- parser3/src/classes/string.C 2002/09/18 08:52:49 1.120 +++ parser3/src/classes/string.C 2002/12/09 11:07:39 1.123 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char* IDENT_STRING_C="$Date: 2002/09/18 08:52:49 $"; +static const char* IDENT_STRING_C="$Date: 2002/12/09 11:07:39 $"; #include "classes.h" #include "pa_request.h" @@ -37,11 +37,15 @@ static void _length(Request& r, const St static void _int(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); + const String *self_string=r.get_self()->get_string(); int converted; - Value *default_code=params->size()>0? - default_code=¶ms->as_junction(0, "default must be int"):0; // (default) + Value *default_code=params->size()>0?¶ms->as_junction(0, "default must be int"):0; // (default) try { - converted=r.get_self()->as_int(); + if(!self_string || self_string->is_empty()) + throw Exception("parser.runtime", + &method_name, + "parameter is empty string, error converting"); + converted=self_string->as_int(); } catch(...) { // convert problem if(!default_code) // we have a problem when no default /*re*/throw; @@ -53,11 +57,15 @@ static void _int(Request& r, const Strin static void _double(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); + const String *self_string=r.get_self()->get_string(); double converted; - Value *default_code=params->size()>0? - default_code=¶ms->as_junction(0, "default must be double"):0; // (default) + Value *default_code=params->size()>0?¶ms->as_junction(0, "default must be double"):0; // (default) try { - converted=r.get_self()->as_double(); + if(!self_string || self_string->is_empty()) + throw Exception("parser.runtime", + &method_name, + "parameter is empty string, error converting"); + converted=self_string->as_double(); } catch(...) { // convert problem if(!default_code) // we have a problem when no default /*re*/throw; @@ -358,7 +366,7 @@ static void _lower(Request& r, const Str class String_sql_event_handlers : public SQL_Driver_query_event_handlers { public: String_sql_event_handlers(Pool& apool, - const String& astatement_string, const char *astatement_cstr) : + const String& astatement_string, const char *astatement_cstr): pool(apool), statement_string(astatement_string), statement_cstr(astatement_cstr), @@ -368,7 +376,7 @@ public: void add_column(void *ptr, size_t size) { if(got_column) - throw Exception("parser.runtime", + throw SQL_Exception("parser.runtime", &statement_string, "result must contain exactly one column"); got_column=true; @@ -377,7 +385,7 @@ public: void add_row() { /* ignore */ } void add_row_cell(void *ptr, size_t size) { if(got_cell) - throw Exception("parser.runtime", + throw SQL_Exception("parser.runtime", &statement_string, "result must not contain more then one row"); got_cell=true; @@ -494,7 +502,7 @@ static void _save(Request& r, const Stri } // write - const char *buf=src.cstr(String::UL_UNSPECIFIED); + const char *buf=src.cstr(String::UL_UNSPECIFIED, r.connection(0/*no error if none*/)); file_write(r.absolute(file_name), buf, strlen(buf), true, do_append); }