Commit 95897d64d66ba8707c73220f67e62018bc8a8910
1 parent
a20a64aa
Exists in
master
and in
5 other branches
Implementando tratamento de excessões na extensão rexx
Showing
5 changed files
with
38 additions
and
11 deletions
Show diff stats
src/plugins/rx3270/exception.cc
src/plugins/rx3270/local.cc
... | ... | @@ -330,7 +330,7 @@ dynamic::dynamic() |
330 | 330 | FreeLibrary(kernel); |
331 | 331 | |
332 | 332 | if(!hModule) |
333 | - return; | |
333 | + throw exception("Can't load %s",dllname); | |
334 | 334 | |
335 | 335 | |
336 | 336 | #else |
... | ... | @@ -339,8 +339,7 @@ dynamic::dynamic() |
339 | 339 | hModule = dlopen("lib3270.so." PACKAGE_VERSION, RTLD_NOW); |
340 | 340 | if(!hModule) |
341 | 341 | { |
342 | - fprintf(stderr,"Can't load lib3270\n%s\n",dlerror()); | |
343 | - fflush(stderr); | |
342 | + throw exception("Can't load lib3270: %s",dlerror()); | |
344 | 343 | return; |
345 | 344 | } |
346 | 345 | |
... | ... | @@ -358,10 +357,10 @@ dynamic::dynamic() |
358 | 357 | if(!*call[f].entry) |
359 | 358 | { |
360 | 359 | #ifndef WIN32 |
361 | - fprintf(stderr,"Can't load lib3270::%s\n%s\n",call[f].name,dlerror()); | |
362 | - fflush(stderr); | |
360 | + throw exception("Error \"%s\" loading lib3270::%s",dlerror(),call[f].name); | |
363 | 361 | dlclose(hModule); |
364 | 362 | #else |
363 | + throw exception("Error loading lib3270::%s",call[f].name); | |
365 | 364 | FreeLibrary(hModule); |
366 | 365 | #endif // !WIN32 |
367 | 366 | hModule = NULL; | ... | ... |
src/plugins/rx3270/remote.cc
... | ... | @@ -170,7 +170,7 @@ remote::remote(const char *name) |
170 | 170 | |
171 | 171 | if(!WaitNamedPipe(buffer,NMPWAIT_USE_DEFAULT_WAIT)) |
172 | 172 | { |
173 | - throw exception("%s","Invalid service instance"); | |
173 | + throw exception("Invalid service instance: %s",name); | |
174 | 174 | return; |
175 | 175 | } |
176 | 176 | |
... | ... | @@ -178,7 +178,7 @@ remote::remote(const char *name) |
178 | 178 | |
179 | 179 | if(hPipe == INVALID_HANDLE_VALUE) |
180 | 180 | { |
181 | - throw exception("%s","Can´t create service pipe"); | |
181 | + throw exception("Can´t create service pipe %s",buffer); | |
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
... | ... | @@ -312,6 +312,15 @@ remote::remote(const char *name) |
312 | 312 | |
313 | 313 | trace("%s: Using DBUS name %s",__FUNCTION__,busname); |
314 | 314 | |
315 | + DBusMessage * msg = create_message("setScript"); | |
316 | + | |
317 | + if(msg) | |
318 | + { | |
319 | + const char * id = "r"; | |
320 | + static const dbus_int32_t flag = 1; | |
321 | + dbus_message_append_args(msg, DBUS_TYPE_STRING, &id, DBUS_TYPE_INT32, &flag, DBUS_TYPE_INVALID); | |
322 | + get_intval(call(msg)); | |
323 | + } | |
315 | 324 | |
316 | 325 | #else |
317 | 326 | |
... | ... | @@ -327,6 +336,21 @@ remote::~remote() |
327 | 336 | |
328 | 337 | #elif defined(HAVE_DBUS) |
329 | 338 | |
339 | + try | |
340 | + { | |
341 | + DBusMessage * msg = create_message("setScript"); | |
342 | + if(msg) | |
343 | + { | |
344 | + const char * id = "r"; | |
345 | + static const dbus_int32_t flag = 0; | |
346 | + dbus_message_append_args(msg, DBUS_TYPE_STRING, &id, DBUS_TYPE_INT32, &flag, DBUS_TYPE_INVALID); | |
347 | + get_intval(call(msg)); | |
348 | + } | |
349 | + } | |
350 | + catch(rx3270::exception e) | |
351 | + { | |
352 | + } | |
353 | + | |
330 | 354 | free(dest); |
331 | 355 | free(path); |
332 | 356 | free(intf); | ... | ... |
src/plugins/rx3270/rx3270.h
... | ... | @@ -64,6 +64,7 @@ |
64 | 64 | #define REXX_DEFAULT_CHARSET "UTF-8" |
65 | 65 | #endif // WIN32 |
66 | 66 | |
67 | +#include <exception> | |
67 | 68 | |
68 | 69 | /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/ |
69 | 70 | |
... | ... | @@ -144,7 +145,7 @@ |
144 | 145 | |
145 | 146 | public: |
146 | 147 | |
147 | - class exception | |
148 | + class exception : public std::exception | |
148 | 149 | { |
149 | 150 | public: |
150 | 151 | exception(int code, const char *fmt, ...); |
... | ... | @@ -156,6 +157,8 @@ |
156 | 157 | void RaiseException(RexxMethodContext *context); |
157 | 158 | void RaiseException(RexxCallContext *context); |
158 | 159 | |
160 | + virtual const char * what() const throw(); | |
161 | + | |
159 | 162 | private: |
160 | 163 | int code; |
161 | 164 | char msg[4096]; |
... | ... | @@ -186,7 +189,6 @@ |
186 | 189 | virtual char * get_revision(void); |
187 | 190 | virtual LIB3270_CSTATE get_cstate(void) = 0; |
188 | 191 | |
189 | - | |
190 | 192 | virtual int connect(const char *uri, bool wait = true) = 0; |
191 | 193 | virtual int disconnect(void) = 0; |
192 | 194 | virtual bool is_connected(void) = 0; | ... | ... |