Usenet comp.unix.osf.misc (1992-2004)
 help / color / mirror / Atom feed
From: nayeri@slbh13.bln.sel.alcatel.de (nader nayeri)
Subject: error handling in DCE-based applications
Date: Tue, 25 Oct 1994 09:03:02 GMT	[thread overview]
Message-ID: <NAYERI.94Oct25100302@slbh13.bln.sel.alcatel.de> (raw)

Together with HP DCE a sample application is shipped called 'phone_db'. The
application contains the following code for error handling:

unsigned32 pdb_print_error(unsigned32 err_num, char *prefix)
{
    int				_ignore;
    dce_error_string_t		dce_err_string;	/* text describing error code */
    char			err_buf[dce_c_error_string_len + 80];
    char *			cp = NULL;

    sprintf(err_buf, "%s: ", prefix);

    if (err_num > 512) {
	/* 
	 * Then the error must be a DCE error.
	 */
	dce_error_inq_text(err_num, dce_err_string, &_ignore);
	cp = (char *)dce_err_string;
    } else if (err_num >= 256) {
        cp = pdb_app_error_string(err_num);

    } else if (err_num > 0) {
	/*
	 * This is a system errno, not a DCE error.
	 */
	cp = strerror(err_num);
    }

    if (cp != NULL)
	strcat(err_buf, cp);

    fprintf(stderr, "%s\n", err_buf);
    if (tr_handle != NULL)
	tr_printmsg(tr_handle, NULL, err_buf);

    return err_num;
}

This seems to me to be an elegant way to handle errors in an
uniform way. But would this solution also work on other UNIX platforms (SUN)? 
I mean, how can I be sure that the numeric constants used in the code 
(512, 256) are not (or are they) platform specific? Is there any way to 
rewrite the code in a more portable manner?


             reply	other threads:[~1994-10-25  9:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-10-25  9:03 nader nayeri [this message]
1994-10-25 17:21 ` error handling in DCE-based applications Mustafizur Rahman
1994-10-27 16:26 ` Rich Salz
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox