contents of r3905, a rather large commit

r3905 commits all of the changes from uckelman-current 3640:HEAD to the
trunk. I’m summarizing a few things that other people should know about
the changes I made here:

  1. New utility classes: The following new utility classes are in
    VASSAL.tools: FileUtils, ErrorUtils, and URLUtils. These contain some
    common code for handling files, errors, and URLs, respectively.

  2. When you catch a Throwable which is a bug, pass it on to
    ErrorDialog.bug(Throwable). If you need to display some other kind of
    error or warning dialog, have a look at some of the other methods in
    ErrorDialog. If it’s an I/O error, use ReadErrorDialog and
    WriteErrorDialog.

  3. ArchiveWriter tries to be more efficient when modifying ZIPs now,
    by not reading whole files into memory when copying them from one ZIP
    to another. This should result in better performance when saving modules,
    especially modules which contain large images. (If it turns out to be
    worse, please tell me.)

  4. ImageOp now has a synchronous getImage() method which throws nothing
    and handles errors internally. It turns out that this was the most common
    use case for fetching small images, and simplifies greatly almost all code
    where images are used (except Board, where asynchronous fetching really
    matters).

  5. There are now a huge number of catch blocks marked with

// FIXME: review error message

These are catch blocks which I haven’t yet examined for correctness. If
you’re working on some code and see one of these, please have a look to
see if the catch block really does handle the error properly. Most of
the ones which are left either involve (a) validating user input, or (b)
are in the VASSAL.chat hierarchy. I intend to keep chipping away at these,
but for most of the ones which are left, I don’t know what the correct
behavior is (though I suspect that in many cases we should be warning the
user rather than silently eating the exception), so I would be grateful
to anyone who wants to spend some time examining these.

  1. VASSAL.tools.version contains a bunch of classes for parsing version
    numbers. Some of these classes are not yet used anywhere, but will be
    soon (I hope). In particular, there is the Version class, which
    encapsulates a pre-parsed version number, in order to reduce expensive
    reparsing.

Thus spake “Michael Kiefte”:

ErrorLog.handle() is the error handler of last resort, and catches
anything which reaches the top of the call stack. Exceptions which go to
the top are bugs, so everything which ErrorLog.handle() recieves is
passed on to ErrorDialog.bug().

Any Throwable which is passed upward but is caught explicitly somewhere
is handled however the code there says to handle it, depending on what
the Throwable is. The most common cases are IOExceptions eventually
being passed to a ReadErrorDialog or WriteErrorDialog. Almost everyting
else is a bug, and handed off to ErrorDialog.bug(), though there are
a small number of oddities which are not bugs and are eventually given
to ErrorDialog.error() or ErrorDialog.warning().


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Michael Kiefte”:

I haven’t had time to do this yet, but I’d like to make a distinction for
error handling purposes between format errors, bugs, and I/O errors. Right
now, there are a lot of places where we conflate the three.

As a rule of thumb, I’d say that anything which happens while reading input
which is not a true I/O error (e.g., couldn’t read/couldn’t find the file)
or an unchecked exception is a format error. I’d like to have a special
exception, say FileFormatException, and a special dialog, say
FileFormatErrorDialog, for handling these.

The bugs I mean to be sent to ErrorDialog.bug() are uncaught exceptions
and exceptions thrown due to getting into states which should be
impossible.

J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Michael Kiefte”:

Oh, I see. Maybe what’s needed for importers is a modified BugDialog?


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)