[fpc-pascal]exception handling

Michael Van Canneyt michael.vancanneyt at wisa.be
Wed Mar 17 14:27:28 CET 2004

On Tue, 16 Mar 2004, kractor wrote:

> spent a few moments going over the docs in the manual re: exception
> handling. for some reason it just doesn't seem to be sinking in, as
> nothing i've tried as of yet has managed to stop prog from crashing when
> data in input that's of a different type than program is expecting
> (string as opposed to integer, for example).
> as i said, i'm pretty sure that its something really small and obvious,
> i'll include a few lines here ... maybe someone can spot my mistake ...
> pretty sure its the EConvertError and that there's a pre-defined error
> type that I just haven't come across yet.
>         try
>             readln(NewAlbum.Year);
>         except
>             on EConvertError do NewAlbum.Year := 0;
>         end;

This should be:

          on E : EConvertError do NewAlbum.Year := 0;


More information about the fpc-pascal mailing list