home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / Samples / SprocketExamples / SprocketInvaders / Source / ErrorHandler.c < prev    next >
Encoding:
Text File  |  1998-07-14  |  3.1 KB  |  126 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        ErrorHandler.c
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                xxx put dri here xxx
  13.  
  14.         Other Contact:        xxx put other contact here xxx
  15.  
  16.         Technology:            xxx put technology here xxx
  17.  
  18.     Writers:
  19.  
  20.         (sjb)    Steve Bollinger
  21.         (BWS)    Brent Schorsch
  22.  
  23.     Change History (most recent first):
  24.  
  25.          <9>     6/18/98    sjb        InputSprocket.h comes from <> place
  26.          <8>     6/12/98    BWS        Now uses InputSprocket 68k
  27. */
  28.  
  29. //•    ------------------------------------------------------------------------------------------    •
  30. //•
  31. //•    Copyright © 1996 Apple Computer, Inc., All Rights Reserved
  32. //•
  33. //•
  34. //•        You may incorporate this sample code into your applications without
  35. //•        restriction, though the sample code has been provided "AS IS" and the
  36. //•        responsibility for its operation is 100% yours.  However, what you are
  37. //•        not permitted to do is to redistribute the source as "DSC Sample Code"
  38. //•        after having made changes. If you're going to re-distribute the source,
  39. //•        we require that you make it clear in the source that the code was
  40. //•        descended from Apple Sample Code, but that you've made changes.
  41. //•
  42. //•        Authors:
  43. //•            Chris De Salvo
  44. //•
  45. //•    ------------------------------------------------------------------------------------------    •
  46.  
  47. //•    ------------------------------    Includes
  48.  
  49. #include <Dialogs.h>
  50. #include <Processes.h>
  51. #include <TextUtils.h>
  52.  
  53. #include <string.h>
  54.  
  55. #include <InputSprocket.h>
  56.  
  57. #include "ErrorHandler.h"
  58. #include "SIResources.h"
  59.  
  60. //•    ------------------------------    Private Definitions
  61. //•    ------------------------------    Private Constants
  62. //•    ------------------------------    Private Types
  63. //•    ------------------------------    Private Structs
  64. //•    ------------------------------    Private Variables
  65. //•    ------------------------------    Private Functions
  66. //•    ------------------------------    Public Variables
  67.  
  68. //•    ------------------------------    FatalError
  69.  
  70. void
  71. FatalError(char *error)
  72. {
  73. Str255    errorHeader;
  74. UInt8    errorString[256];
  75.  
  76.     strcpy((char *) errorString + 1, error);
  77.     errorString[0] = strlen((char *) errorString + 1);
  78.     GetIndString(errorHeader, kSTRMessageStrings, kSTRiFatal);
  79.  
  80.     ISpSuspend();
  81.     
  82.     ParamText(errorHeader, errorString, "\p", "\p");
  83.     if (Alert(kALRTFatal, nil) == cancel)
  84.         Debugger();
  85.     
  86.     ExitToShell();
  87. }
  88.  
  89. //•    ------------------------------    NonFatalError
  90.  
  91. void
  92. NonFatalError(char *error)
  93. {
  94. Str255    errorHeader;
  95. UInt8    errorString[256];
  96.  
  97.     strcpy((char *) errorString + 1, error);
  98.     errorString[0] = strlen((char *) errorString + 1);
  99.     GetIndString(errorHeader, kSTRMessageStrings, kSTRiNonFatal);
  100.  
  101.     ISpSuspend();
  102.     
  103.     ParamText(errorHeader, errorString, "\p", "\p");
  104.     Alert(kALRTNonFatal, nil);
  105. }
  106.  
  107. //•    ------------------------------    MessageError
  108.  
  109. short
  110. MessageError(char *error1, char *error2)
  111. {
  112. UInt8    errorString1[256];
  113. UInt8    errorString2[256];
  114.  
  115.     strcpy((char *) errorString1 + 1, error1);
  116.     errorString1[0] = strlen((char *) errorString1 + 1);
  117.  
  118.     strcpy((char *) errorString2 + 1, error2);
  119.     errorString2[0] = strlen((char *) errorString2 + 1);
  120.  
  121.     ISpSuspend();
  122.     
  123.     ParamText(errorString1, errorString2, "\p", "\p");
  124.     return (Alert(kALRTMessage, nil));
  125. }
  126.