Browse Source

Format error now causes exception

michael 27 years ago
parent
commit
5046369285
2 changed files with 36 additions and 6 deletions
  1. 8 1
      rtl/objpas/stre.inc
  2. 28 5
      rtl/objpas/sysstr.inc

+ 8 - 1
rtl/objpas/stre.inc

@@ -26,6 +26,7 @@ Const
    SAbstractError = 'Abstract method called';
    SAbstractError = 'Abstract method called';
    SAccessDenied = 'Access denied';
    SAccessDenied = 'Access denied';
    SAccessViolation = 'Access violation';
    SAccessViolation = 'Access violation';
+   SArgumentMissing = 'Missing argument in format "%s"';
    SDiskFull = 'Disk Full';
    SDiskFull = 'Disk Full';
    SDivByZero = 'Division by zero';
    SDivByZero = 'Division by zero';
    SEndOfFile = 'Read past end of file'; 
    SEndOfFile = 'Read past end of file'; 
@@ -33,10 +34,13 @@ Const
    SFileNotOpen = 'File not open';
    SFileNotOpen = 'File not open';
    SFileNotOpenForInput = 'File not open for input';
    SFileNotOpenForInput = 'File not open for input';
    SFileNotOpenForOutput = 'File not open for output';
    SFileNotOpenForOutput = 'File not open for output';
+   SInvalidArgIndex = 'Invalid argument index in format "%s"';
    SInvalidDrive = 'Invalid drive specified';
    SInvalidDrive = 'Invalid drive specified';
    SInvalidFileHandle = 'Invalid file handle';
    SInvalidFileHandle = 'Invalid file handle';
    SInValidFileName = 'Invalid filename';
    SInValidFileName = 'Invalid filename';
+   SInvalidFormat = 'Invalid format specifier : "%s"';
    SInvalidInput = 'Invalid input';
    SInvalidInput = 'Invalid input';
+   SInvalidInteger = '"%s" is an invalid integer';
    SInvalidPointer = 'Invalid pointer operation';
    SInvalidPointer = 'Invalid pointer operation';
    SOutOfMemory = 'Out of memory';
    SOutOfMemory = 'Out of memory';
    SRangeError = 'Range check error';
    SRangeError = 'Range check error';
@@ -44,7 +48,10 @@ Const
    SUnKnownRunTimeError = 'Unknown Run-Time error : %3.3d';
    SUnKnownRunTimeError = 'Unknown Run-Time error : %3.3d';
 {
 {
   $Log$
   $Log$
-  Revision 1.2  1998-10-02 13:00:09  michael
+  Revision 1.3  1998-10-02 13:57:37  michael
+  Format error now causes exception
+
+  Revision 1.2  1998/10/02 13:00:09  michael
   + More RTL error handling
   + More RTL error handling
 
 
   Revision 1.1  1998/10/01 16:04:59  michael
   Revision 1.1  1998/10/01 16:04:59  michael

+ 28 - 5
rtl/objpas/sysstr.inc

@@ -404,10 +404,16 @@ end ;
     if S does not represent a valid integer value EConvertError is raised  }
     if S does not represent a valid integer value EConvertError is raised  }
 
 
 function StrToInt(const S: string): integer;
 function StrToInt(const S: string): integer;
+
 var Error: word;
 var Error: word;
+
 begin
 begin
  Val(S, result, Error);
  Val(S, result, Error);
- if Error <> 0 then raise EConvertError.create(s + ' is not a valid integer');
+{$ifdef autoobjpas}
+  if Error <> 0 then raise EConvertError.createfmt(SInValidInteger,[S]);
+{$else}
+  if Error <> 0 then raise EConvertError.create(s + ' is not a valid integer');
+{$endif}
 end ;
 end ;
 
 
 {   StrToIntDef converts the string S to an integer value,
 {   StrToIntDef converts the string S to an integer value,
@@ -450,9 +456,20 @@ end;
    
    
 Procedure DoFormatError (ErrCode : Longint);
 Procedure DoFormatError (ErrCode : Longint);
 
 
+Var S : String;
+
 begin
 begin
-  Writeln ('Error in format : ',Errcode);
-  Halt(1);
+  //!! must be changed to contain format string...
+  S:='';
+{$ifdef autoobjpas}
+  Case ErrCode of
+   feInvalidFormat : EConvertError.Createfmt(SInvalidFormat,[s]);
+   feMissingArgument : EConvertError.Createfmt(SArgumentMissing,[s]);
+   feInvalidArgIndex : EConvertError.Createfmt(SInvalidArgIndex,[s]);
+ end;
+{$else}
+  EConvertError.Create('Invalid format encountered : '+S);
+{$endif}
 end;
 end;
 
 
 {$ifdef AUTOOBJPAS}
 {$ifdef AUTOOBJPAS}
@@ -889,7 +906,10 @@ end ;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.7  1998-10-02 12:17:17  michael
+  Revision 1.8  1998-10-02 13:57:38  michael
+  Format error now causes exception
+
+  Revision 1.7  1998/10/02 12:17:17  michael
   + Made sure it compiles with official 0.99.8
   + Made sure it compiles with official 0.99.8
 
 
   Revision 1.6  1998/10/02 10:42:17  michael
   Revision 1.6  1998/10/02 10:42:17  michael
@@ -909,7 +929,10 @@ end ;
   Update from gertjan Schouten, plus small fix for linux
   Update from gertjan Schouten, plus small fix for linux
 
 
   $Log$
   $Log$
-  Revision 1.7  1998-10-02 12:17:17  michael
+  Revision 1.8  1998-10-02 13:57:38  michael
+  Format error now causes exception
+
+  Revision 1.7  1998/10/02 12:17:17  michael
   + Made sure it compiles with official 0.99.8
   + Made sure it compiles with official 0.99.8
 
 
   Revision 1.6  1998/10/02 10:42:17  michael
   Revision 1.6  1998/10/02 10:42:17  michael