xverror.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* XView error handling routines.
  2. Copyright (C) 1995 Jakub Jelinek.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
  14. #include <config.h>
  15. #include <xview/xview.h>
  16. #include <xview/frame.h>
  17. #include <xview/notice.h>
  18. extern Frame mcframe;
  19. int xv_error_handler (Xv_object object, Attr_avlist avlist)
  20. {
  21. Attr_avlist attrs;
  22. Error_severity severity = ERROR_RECOVERABLE;
  23. int n = 0;
  24. char str1[64], str2[64], str3[64], str4[64], str5[64], str6[64], str7[64];
  25. char *strs [7];
  26. strs [0] = str1; strs [1] = str2; strs [2] = str3; strs [3] = str4;
  27. strs [4] = str5; strs [5] = str6; strs [6] = str7;
  28. for (attrs = avlist; *attrs && n < 5; attrs = attr_next (attrs)) {
  29. switch ((int) attrs [0]) {
  30. case ERROR_BAD_ATTR:
  31. sprintf (strs [n++], "bad attribute %s",
  32. attr_name (attrs [1]));
  33. break;
  34. case ERROR_BAD_VALUE:
  35. sprintf (strs [n++], "bad value (0x%x) for attribute %s",
  36. (int) attrs [1], attr_name (attrs [2]));
  37. break;
  38. case ERROR_INVALID_OBJECT:
  39. sprintf (strs [n++], "invalid object (%s)",
  40. (char *) attrs [1]);
  41. break;
  42. case ERROR_STRING:
  43. sprintf (strs [n++], "%s",
  44. (char *) attrs [1]);
  45. break;
  46. case ERROR_PKG:
  47. sprintf (strs [n++], "Package: %s",
  48. ((Xv_pkg *) attrs [1])->name);
  49. break;
  50. case ERROR_SEVERITY:
  51. severity = attrs [1];
  52. }
  53. }
  54. strcpy (strs [n++], "Dump core?");
  55. strs [n] = NULL;
  56. #ifdef NICE_DEBUG
  57. if (notice_prompt (mcframe, (Event *) NULL,
  58. NOTICE_MESSAGE_STRINGS_ARRAY_PTR, strs,
  59. NOTICE_BUTTON_YES, "Yes",
  60. NOTICE_BUTTON_NO, "No",
  61. NULL) == NOTICE_YES)
  62. abort ();
  63. #endif
  64. if (severity == ERROR_NON_RECOVERABLE)
  65. exit (1);
  66. return (XV_OK);
  67. }