Re: [fpc-pascal] Choice of exceptions to use?

2023-06-04 Thread Bart via fpc-pascal
On Sun, Jun 4, 2023 at 11:58 AM Graeme Geldenhuys via fpc-pascal
 wrote:

> Initially I was leaning towards the Range exception, but now I'm
> thinking that maybe the Argument exception is more appropriate
> (based on the descriptions seen in the linked docs).

I would go for range exception, since the offending coordinates are
out of range.
Invalid Argument for me would apply to situations like a wrong type
for a format specifier.


-- 
Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Choice of exceptions to use?

2023-06-04 Thread Graeme Geldenhuys via fpc-pascal
Hi,

I'm working on code where the function take a (x, y) set of coordinates.
If the coordinates are out of range/bounds, I want to raise an exception
with a message explaining the reason and limits. I definitely don't want
to "silently do nothing".

Looking at these set of built-in exceptions:
  https://www.freepascal.org/docs-html/rtl/sysutils/index-4.html


I'm in two-minds as to which exception to raise. Seems my choices are:

* EArgumentException - an invalid argument was passed to the method
* ERangeException - I could interpret this as the values passed in,
were not in the allowed range.

Initially I was leaning towards the Range exception, but now I'm
thinking that maybe the Argument exception is more appropriate
(based on the descriptions seen in the linked docs).

What's your thoughts?

Regards,
  Graeme
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal