Sponsored Content
Top Forums Programming C++ - 'try, throw, catch' compare to regular C-style 'if' - advantages? Post 302901598 by alex_5161 on Wednesday 14th of May 2014 12:53:55 PM
Old 05-14-2014
Thanks, Corona688, for reply and sharing your thoughts on that matter!
The point about following the Java style is reasonable (while, actually, not big deal.)
'Cleaner' ?, hmm, hard to be agree, but it is not a point to discuss: just personal opinion.
Others points I see in your review are: propagate up to where it will be decided to process.
That is, definitely, benefits: in C it could be done by special additional coding that is not pleasant to write and not nice usually.

The benefit of catching everything, even dot defined error, also is something: not handled error will be processed by system, but C error processing have no mechanism to 'prepare' any how to getting out of program.
Sure, it is useful.

And, finally, I have realized some 'coding layout' benefits:
- initial 'strait forward' C-error handling assume checking for an error and processing it in place where it could occur.
- the C++ style by that mechanizm is offering the syntax that provides the chance to move the error handling activity out of main business logic ( like in C having a separate function to check of any error condition where all possible errors would be defined, checked and processed when heppened.)

Sure, all those make sense to use it!

Appreciate your input and chance to realize all that!

THANKS!
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Linux advantages?

Hello to help me with my studying of unix/linux outside of work I was thinking of installing Linux at home aswell as using Windows XP. Im pretty new to Linux and Unix, could someone tell me the possible benifits or even negatives of running Linux at home as an opperating system as opposed to... (2 Replies)
Discussion started by: Loaded Gun
2 Replies

2. UNIX for Dummies Questions & Answers

Advantages of Groups

What are the advantages of putting users into groups? I understand that in a corporate environment, you should create a group for each department. ie: putting finance employees into a finance group. But are there any system advantages for doing that? How would it make it easier on the system... (3 Replies)
Discussion started by: kurtmc
3 Replies

3. Shell Programming and Scripting

advantages of Perl ?

What is the advantages of Perl in Unix environnement. Is it for scripts ? Text manipulation ? Have you a Concrete exemple of perl utilisation. Thanks you (3 Replies)
Discussion started by: simquest
3 Replies

4. Shell Programming and Scripting

compare variable against regular expression?

is it possible? if so, how? i want to check a variable whether is it a number or letter in an if-else statement (6 Replies)
Discussion started by: finalight
6 Replies

5. Shell Programming and Scripting

AWK - compare $0 to regular expression + variable

Hi, I have this script: awk -v va=45 '$0~va{print}' flo2 That returns: "4526745 1234 " (this is the only line of the file "flo2". However, I would like to get "va" to match the begining of the line, so that is "va" is different than 45 (eg. 67, 12 ...) I would not have any output. That... (3 Replies)
Discussion started by: jolecanard
3 Replies

6. Shell Programming and Scripting

How to compare a file name with a regular expression !!

Hi, I need to compare file names in a folder with several strings(which are in regular expression format): For example: there is a file "objectMyHistoryBook" and there are several strings to compare this file name with: objectMyMaths*, objectMyEnglish*, objectMyHistory*,... (2 Replies)
Discussion started by: Lucifer_123
2 Replies

7. UNIX for Dummies Questions & Answers

What are some advantages of Unix?

What are some advantage's of Unix (3 Replies)
Discussion started by: alvin2132
3 Replies

8. UNIX for Dummies Questions & Answers

Compare files with regular expression

Readers, Reading a previous post about comparing files using awk ('awk-compare-2-columns-2-files-output-whole-line', https://www.unix.com/shell-programming-scripting/168432-awk-compare-2-columns-2-files-output-whole-line.html), it is possible to adjust this, so that regular expression can be used... (8 Replies)
Discussion started by: linuxr
8 Replies
Tk_CreateErrorHandler(3)				       Tk Library Procedures					  Tk_CreateErrorHandler(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_CreateErrorHandler, Tk_DeleteErrorHandler - handle X protocol errors SYNOPSIS
#include <tk.h> Tk_ErrorHandler Tk_CreateErrorHandler(display, error, request, minor, proc, clientData) Tk_DeleteErrorHandler(handler) ARGUMENTS
Display *display (in) Display whose errors are to be handled. int error (in) Match only error events with this value in the error_code field. If -1, then match any error_code value. int request (in) Match only error events with this value in the request_code field. If -1, then match any request_code value. int minor (in) Match only error events with this value in the minor_code field. If -1, then match any minor_code value. Tk_ErrorProc *proc (in) Procedure to invoke whenever an error event is received for display and matches error, request, and minor. NULL means ignore any matching errors. ClientData clientData (in) Arbitrary one-word value to pass to proc. Tk_ErrorHandler handler (in) Token for error handler to delete (return value from a previous call to Tk_CreateErrorHandler). _________________________________________________________________ DESCRIPTION
Tk_CreateErrorHandler arranges for a particular procedure (proc) to be called whenever certain protocol errors occur on a particular dis- play (display). Protocol errors occur when the X protocol is used incorrectly, such as attempting to map a window that does not exist. See the Xlib documentation for XSetErrorHandler for more information on the kinds of errors that can occur. For proc to be invoked to han- dle a particular error, five things must occur: [1] The error must pertain to display. [2] Either the error argument to Tk_CreateErrorHandler must have been -1, or the error argument must match the error_code field from the error event. [3] Either the request argument to Tk_CreateErrorHandler must have been -1, or the request argument must match the request_code field from the error event. [4] Either the minor argument to Tk_CreateErrorHandler must have been -1, or the minor argument must match the minor_code field from the error event. [5] The protocol request to which the error pertains must have been made when the handler was active (see below for more information). Proc should have arguments and result that match the following type: typedef int Tk_ErrorProc( ClientData clientData, XErrorEvent *errEventPtr); The clientData parameter to proc is a copy of the clientData argument given to Tcl_CreateErrorHandler when the callback was created. Typi- cally, clientData points to a data structure containing application-specific information that is needed to deal with the error. ErrEventPtr is a pointer to the X error event. The procedure proc should return an integer value. If it returns 0 it means that proc han- dled the error completely and there is no need to take any other action for the error. If it returns non-zero it means proc was unable to handle the error. If a value of NULL is specified for proc, all matching errors will be ignored: this will produce the same result as if a procedure had been specified that always returns 0. If more than more than one handler matches a particular error, then they are invoked in turn. The handlers will be invoked in reverse order of creation: most recently declared handler first. If any handler returns 0, then subsequent (older) handlers will not be invoked. If no handler returns 0, then Tk invokes X's default error handler, which prints an error message and aborts the program. If you wish to have a default handler that deals with errors that no other handler can deal with, then declare it first. The X documentation states that "the error handler should not call any functions (directly or indirectly) on the display that will generate protocol requests or that will look for input events." This restriction applies to handlers declared by Tk_CreateErrorHandler; disobey it at your own risk. Tk_DeleteErrorHandler may be called to delete a previously-created error handler. The handler argument identifies the error handler, and should be a value returned by a previous call to Tk_CreateEventHandler. A particular error handler applies to errors resulting from protocol requests generated between the call to Tk_CreateErrorHandler and the call to Tk_DeleteErrorHandler. However, the actual callback to proc may not occur until after the Tk_DeleteErrorHandler call, due to buffering in the client and server. If an error event pertains to a protocol request made just before calling Tk_DeleteErrorHandler, then the error event may not have been processed before the Tk_DeleteErrorHandler call. When this situation arises, Tk will save information about the handler and invoke the handler's proc later when the error event finally arrives. If an application wishes to delete an error handler and know for certain that all relevant errors have been processed, it should first call Tk_DeleteErrorHandler and then call XSync; this will flush out any buffered requests and errors, but will result in a performance penalty because it requires communication to and from the X server. After the XSync call Tk is guaranteed not to call any error handlers deleted before the XSync call. For the Tk error handling mechanism to work properly, it is essential that application code never calls XSetErrorHandler directly; applica- tions should use only Tk_CreateErrorHandler. KEYWORDS
callback, error, event, handler Tk Tk_CreateErrorHandler(3)
All times are GMT -4. The time now is 02:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy