Procházet zdrojové kódy

+ More RTL error handling

michael před 27 roky
rodič
revize
864454422f
2 změnil soubory, kde provedl 43 přidání a 12 odebrání
  1. 14 3
      rtl/objpas/stre.inc
  2. 29 9
      rtl/objpas/sysutils.pp

+ 14 - 3
rtl/objpas/stre.inc

@@ -23,20 +23,31 @@ Const
 
    { Error messages for exceptions }
    
+   SAbstractError = 'Abstract method called';
    SAccessDenied = 'Access denied';
+   SAccessViolation = 'Access violation';
    SDiskFull = 'Disk Full';
+   SDivByZero = 'Division by zero';
    SEndOfFile = 'Read past end of file'; 
+   SFileNotAssigned = 'File not assigned';
+   SFileNotOpen = 'File not open';
+   SFileNotOpenForInput = 'File not open for input';
+   SFileNotOpenForOutput = 'File not open for output';
+   SInvalidDrive = 'Invalid drive specified';
+   SInvalidFileHandle = 'Invalid file handle';
    SInValidFileName = 'Invalid filename';
    SInvalidInput = 'Invalid input';
    SInvalidPointer = 'Invalid pointer operation';
    SOutOfMemory = 'Out of memory';
+   SRangeError = 'Range check error';
    STooManyOpenFiles = 'Too many open files';
    SUnKnownRunTimeError = 'Unknown Run-Time error : %3.3d';
-   
-   
 {
   $Log$
-  Revision 1.1  1998-10-01 16:04:59  michael
+  Revision 1.2  1998-10-02 13:00:09  michael
+  + More RTL error handling
+
+  Revision 1.1  1998/10/01 16:04:59  michael
   + Initial implementation
 
 }   

+ 29 - 9
rtl/objpas/sysutils.pp

@@ -83,13 +83,18 @@ interface
          public
          ErrorCode : Longint;
          end;
-       EInvalidPointer = Class(Exception);
-       EOutOfMemory    = Class(Exception);
+       EInvalidPointer  = Class(Exception);
+       EOutOfMemory     = Class(Exception);
+       EAccessViolation = Class(Exception);
        
-       econverterror = class(exception);
-
-
+       
+       { String conversion errors }
+       EConvertError = class(Exception);
 
+       { Other errors } 
+       EAbort         = Class(Exception);
+       EAbstractError = Class(Exception);
+       
   { Read date & Time function declarations }
   {$i datih.inc}
 
@@ -190,22 +195,34 @@ Var E : Exception;
     
 begin
   Case Errno of
-   1 : E:=OutOfMemory;
+   1,203 : E:=OutOfMemory;
    //!! ?? 2 is a 'file not found error' ??
-   2 : E:=InvalidPointer;
-   3,4,5,100,101,106 : { I/O errors }
+   2,204 : E:=InvalidPointer;
+   3,4,5,6,100,101,102,103,105,106 : { I/O errors }
      begin
      Case Errno of
        3 : S:=SInvalidFileName;
        4 : S:=STooManyOpenFiles;
        5 : S:=SAccessDenied;
+       6 : S:=SInvalidFileHandle;
+       15 : S:=SInvalidDrive;
        100 : S:=SEndOfFile;
        101 : S:=SDiskFull;
+       102 : S:=SFileNotAssigned;
+       103 : S:=SFileNotOpen;
+       104 : S:=SFileNotOpenForInput;
+       105 : S:=SFileNotOpenForOutput;
        106 : S:=SInvalidInput;
      end;
      E:=EinOutError.Create (S);
      EInoutError(E).ErrorCode:=IOresult; // Clears InOutRes !!
      end;
+  // We don't set abstracterrorhandler, but we do it here. 
+  // Unless the use sets another handler we'll get here anyway...
+  200 : E:=EDivByZero.Create(SDivByZero);
+  201 : E:=ERangeError.Create(SRangeError);
+  211 : E:=EAbstractError.Create(SAbstractError);
+  216 : E:=EAccessViolation.Create (SAccessViolation);
   else
 {$ifdef autoobjpas}
    E:=Exception.CreateFmt (SUnKnownRunTimeError,[Errno]);
@@ -237,7 +254,10 @@ begin
 end.
 {
     $Log$
-    Revision 1.12  1998-10-02 12:17:18  michael
+    Revision 1.13  1998-10-02 13:00:11  michael
+    + More RTL error handling
+
+    Revision 1.12  1998/10/02 12:17:18  michael
     + Made sure it compiles with official 0.99.8
 
     Revision 1.11  1998/10/01 16:04:11  michael