ThomasMiz / RectpackSharp

A rectangle packing library for .NET Standard
MIT License
77 stars 12 forks source link

Specific exception class for when the packing algorithm could not find a solution #8

Open pkhead opened 1 month ago

pkhead commented 1 month ago

This is a pretty neat library, but I have one minor qualm about it. It would be nice if, in the case where the pack function could not find a solution, it threw a specific type of exception instead of the generic System.Exception. That way, I can catch that exception specifically and potentially not something else that would be more exceptional.

Additionally, the exception message is misleading in the case where the pack function could not find the solution because it was limited by the specified max bounds size. None of my rectangles were anywhere close to uint.MaxValue, and I used the default stepSize.

And on the topic of the fail case, another thing I found annoying is that what the pack function even does when it couldn't find a solution isn't even documented. I mean, it's not something that seems rare, given the fact that you can choose the maximum bounds of the packed rectangle. I would appreciate it if that was changed.

ThomasMiz commented 1 month ago

Fair request, will do in the next release. Thanks you!