2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: SmError.c /main/5 1998/10/26 17:20:29 mgreess $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
30 /*************************************<+>*************************************
31 *****************************************************************************
35 ** Project: HP DT Session Manager (dtsession)
39 ** This file contains all session manager error functions. The session
40 ** manager traps all errors from the toolkit and server, and takes action
41 ** depending on the type of the error.
45 *******************************************************************
46 ** (c) Copyright Hewlett-Packard Company, 1990. All rights are
47 ** reserved. Copying or other reproduction of this program
48 ** except for archival purposes is prohibited without prior
49 ** written consent of Hewlett-Packard Company.
50 ********************************************************************
54 *****************************************************************************
55 *************************************<+>*************************************/
61 #include <X11/Intrinsic.h>
62 #include <Dt/UserMsg.h>
65 #include "SmGlobals.h"
77 static int LibError( Display *, XErrorEvent *) ;
78 static int LibIOError( void ) ;
79 static void ToolkitWarning( char *) ;
80 static void ToolkitError( char *) ;
84 /*************************************<->*************************************
91 * Initialize all error handlers for use with the session manager
92 * session manager should only exit on real severe conditions.
93 * it should try to gracefully recover on the rest.
107 *************************************<->***********************************/
109 InitErrorHandler( void )
111 XSetErrorHandler(LibError);
112 XSetIOErrorHandler( (IOErrorHandlerProc) LibIOError);
113 XtSetWarningHandler(ToolkitWarning);
114 XtSetErrorHandler(ToolkitError);
118 /*************************************<->*************************************
120 * LibError (display, errorEvent)
125 * X error handler. Takes care of X errors so that the server will
126 * not terminate the session manager on any error.
131 * errorEvent = pointer to error event returned by the server.
140 *************************************<->***********************************/
144 XErrorEvent *errorEvent )
147 switch (errorEvent->error_code)
152 PrintError(DtError, BAD_ACCESS);
155 PrintError(DtError, BAD_ATOM);
158 PrintError(DtError, BAD_DRAWABLE);
161 PrintError(DtError, BAD_MATCH);
164 PrintError(DtError, BAD_VALUE);
167 PrintError(DtError, BAD_WINDOW);
170 PrintError(DtError, DEFAULT_ERROR);
178 /*************************************<->*************************************
185 * IO error handler. In charge of handling IO events from the
199 *************************************<->***********************************/
203 PrintError(DtError, GETMESSAGE(8, 1, "Connection to server lost - exiting."));
209 /*************************************<->*************************************
211 * ToolkitWarning (message)
216 * Handles all toolkit warnings
221 * message = error message sent by toolkit
230 *************************************<->***********************************/
236 PrintError(DtError, message);
242 /*************************************<->*************************************
244 * ToolkitError (message)
249 * Handles all toolkit errors
254 * message = error message sent by toolkit
263 * Xt assumes the client will exit when an XtError is generated
264 * so we must exit since the state will be undefined if we
268 *************************************<->***********************************/
274 PrintError(DtError, message);
279 /*************************************<->*************************************
281 * PrintError (severity, help)
286 * Handles the printing of all session manager errors using the dt API
287 * These are simple errors that don't set errno
292 * severity = severity of the error
293 * help = help message to user (what type of error)
301 * WARNING: Currently the va_alist parameter is not used in the
302 * DtSimpleError is not used
304 *************************************<->***********************************/
310 _DtSimpleError(DtProgName, severity, NULL, "%.2000s", help);
314 /*************************************<->*************************************
316 * PrintErrnoError (severity, help)
321 * Handles the printing of all session manager errors using the dt API
322 * These are simple errors that set errno
327 * severity = severity of the error
328 * help = help message to user (what type of error)
336 * WARNING: Currently the va_alist parameter is not used in the
337 * DtSimpleErrnoError is not used
339 *************************************<->***********************************/
345 _DtSimpleErrnoError(DtProgName, severity, NULL, "%s", help);