When do we throw Exceptions

There are a lot of occasions where Mufasa may throw exceptions.

Consider the following program:

program new;
var
  bmp:integer;
  x, y:integer;
begin
  bmp:=bitmapfromstring(200, 200, '');
  x := -1;
  y := -1;
  fastsetpixel(bmp, x, y, clwhite);
end.

Now, when we execute this with MML, we get this:

Error: Exception: You are accessing an invalid point, (-1,-1) at bitmap[0] at line 8

Further expanding the example:

program new;
var
  bmp:integer;
  x, y:integer;
begin
  bmp:=bitmapfromstring(200, 200, '');
  x := -1;
  y := -1;
  try
  	fastsetpixel(bmp, x, y, clwhite);
  except
  	writeln('We failed to do a setpixel with x = ' + inttostr(x) + 
			', y = ' + inttostr(y));
  end;
end.

Results in:

Compiled succesfully in 8 ms.
We failed to do a setpixel with x = .-1, y = -1
Succesfully executed



Subsections

Merlijn Wajer 2010-08-27