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,7 +330,7 @@ dynamic::dynamic() | ||
330 | FreeLibrary(kernel); | 330 | FreeLibrary(kernel); |
331 | 331 | ||
332 | if(!hModule) | 332 | if(!hModule) |
333 | - return; | 333 | + throw exception("Can't load %s",dllname); |
334 | 334 | ||
335 | 335 | ||
336 | #else | 336 | #else |
@@ -339,8 +339,7 @@ dynamic::dynamic() | @@ -339,8 +339,7 @@ dynamic::dynamic() | ||
339 | hModule = dlopen("lib3270.so." PACKAGE_VERSION, RTLD_NOW); | 339 | hModule = dlopen("lib3270.so." PACKAGE_VERSION, RTLD_NOW); |
340 | if(!hModule) | 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 | return; | 343 | return; |
345 | } | 344 | } |
346 | 345 | ||
@@ -358,10 +357,10 @@ dynamic::dynamic() | @@ -358,10 +357,10 @@ dynamic::dynamic() | ||
358 | if(!*call[f].entry) | 357 | if(!*call[f].entry) |
359 | { | 358 | { |
360 | #ifndef WIN32 | 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 | dlclose(hModule); | 361 | dlclose(hModule); |
364 | #else | 362 | #else |
363 | + throw exception("Error loading lib3270::%s",call[f].name); | ||
365 | FreeLibrary(hModule); | 364 | FreeLibrary(hModule); |
366 | #endif // !WIN32 | 365 | #endif // !WIN32 |
367 | hModule = NULL; | 366 | hModule = NULL; |
src/plugins/rx3270/remote.cc
@@ -170,7 +170,7 @@ remote::remote(const char *name) | @@ -170,7 +170,7 @@ remote::remote(const char *name) | ||
170 | 170 | ||
171 | if(!WaitNamedPipe(buffer,NMPWAIT_USE_DEFAULT_WAIT)) | 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 | return; | 174 | return; |
175 | } | 175 | } |
176 | 176 | ||
@@ -178,7 +178,7 @@ remote::remote(const char *name) | @@ -178,7 +178,7 @@ remote::remote(const char *name) | ||
178 | 178 | ||
179 | if(hPipe == INVALID_HANDLE_VALUE) | 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 | return; | 182 | return; |
183 | } | 183 | } |
184 | 184 | ||
@@ -312,6 +312,15 @@ remote::remote(const char *name) | @@ -312,6 +312,15 @@ remote::remote(const char *name) | ||
312 | 312 | ||
313 | trace("%s: Using DBUS name %s",__FUNCTION__,busname); | 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 | #else | 325 | #else |
317 | 326 | ||
@@ -327,6 +336,21 @@ remote::~remote() | @@ -327,6 +336,21 @@ remote::~remote() | ||
327 | 336 | ||
328 | #elif defined(HAVE_DBUS) | 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 | free(dest); | 354 | free(dest); |
331 | free(path); | 355 | free(path); |
332 | free(intf); | 356 | free(intf); |
src/plugins/rx3270/rx3270.h
@@ -64,6 +64,7 @@ | @@ -64,6 +64,7 @@ | ||
64 | #define REXX_DEFAULT_CHARSET "UTF-8" | 64 | #define REXX_DEFAULT_CHARSET "UTF-8" |
65 | #endif // WIN32 | 65 | #endif // WIN32 |
66 | 66 | ||
67 | +#include <exception> | ||
67 | 68 | ||
68 | /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/ | 69 | /*---[ Rexx entry points ]-----------------------------------------------------------------------------------*/ |
69 | 70 | ||
@@ -144,7 +145,7 @@ | @@ -144,7 +145,7 @@ | ||
144 | 145 | ||
145 | public: | 146 | public: |
146 | 147 | ||
147 | - class exception | 148 | + class exception : public std::exception |
148 | { | 149 | { |
149 | public: | 150 | public: |
150 | exception(int code, const char *fmt, ...); | 151 | exception(int code, const char *fmt, ...); |
@@ -156,6 +157,8 @@ | @@ -156,6 +157,8 @@ | ||
156 | void RaiseException(RexxMethodContext *context); | 157 | void RaiseException(RexxMethodContext *context); |
157 | void RaiseException(RexxCallContext *context); | 158 | void RaiseException(RexxCallContext *context); |
158 | 159 | ||
160 | + virtual const char * what() const throw(); | ||
161 | + | ||
159 | private: | 162 | private: |
160 | int code; | 163 | int code; |
161 | char msg[4096]; | 164 | char msg[4096]; |
@@ -186,7 +189,6 @@ | @@ -186,7 +189,6 @@ | ||
186 | virtual char * get_revision(void); | 189 | virtual char * get_revision(void); |
187 | virtual LIB3270_CSTATE get_cstate(void) = 0; | 190 | virtual LIB3270_CSTATE get_cstate(void) = 0; |
188 | 191 | ||
189 | - | ||
190 | virtual int connect(const char *uri, bool wait = true) = 0; | 192 | virtual int connect(const char *uri, bool wait = true) = 0; |
191 | virtual int disconnect(void) = 0; | 193 | virtual int disconnect(void) = 0; |
192 | virtual bool is_connected(void) = 0; | 194 | virtual bool is_connected(void) = 0; |