From 18d026605590bb6b1d5d9a5a54776281db73a1bb Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 24 Jan 2003 19:32:56 +0000 Subject: [PATCH] Throw a sensible error message if we choke trimming a tileset. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2214 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../tile/bundle/tools/TileSetBundler.java | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java b/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java index 6e251b1eb..0e0da5384 100644 --- a/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java +++ b/src/java/com/threerings/media/tile/bundle/tools/TileSetBundler.java @@ -1,5 +1,5 @@ // -// $Id: TileSetBundler.java,v 1.10 2003/01/13 22:49:47 mdb Exp $ +// $Id: TileSetBundler.java,v 1.11 2003/01/24 19:32:56 mdb Exp $ package com.threerings.media.tile.bundle.tools; @@ -308,26 +308,36 @@ public class TileSetBundler jar.putNextEntry(new JarEntry(imagePath)); // if this is an object tileset, we can't trim it! - if (set instanceof ObjectTileSet) { - // set the tileset up with an image provider; we need to - // do this so that we can trim it! - set.setImageProvider(improv); + try { + if (set instanceof ObjectTileSet) { + // set the tileset up with an image provider; we + // need to do this so that we can trim it! + set.setImageProvider(improv); - // create a trimmed object tileset, which will write - // the trimmed tileset image to the jar output stream - TrimmedObjectTileSet tset = - TrimmedObjectTileSet.trimObjectTileSet( - (ObjectTileSet)set, jar); - tset.setImagePath(imagePath); - // replace the original set with the trimmed tileset - // in the tileset bundle - bundle.addTileSet(tileSetId, tset); + // create a trimmed object tileset, which will + // write the trimmed tileset image to the jar + // output stream + System.out.println("Trimming " + imagePath); + TrimmedObjectTileSet tset = + TrimmedObjectTileSet.trimObjectTileSet( + (ObjectTileSet)set, jar); + tset.setImagePath(imagePath); + // replace the original set with the trimmed + // tileset in the tileset bundle + bundle.addTileSet(tileSetId, tset); - } else { - // open the image and pipe it into the jar file - File imgfile = new File(bundleDesc.getParent(), imagePath); - FileInputStream imgin = new FileInputStream(imgfile); - StreamUtils.pipe(imgin, jar); + } else { + // open the image and pipe it into the jar file + File imgfile = new File(bundleDesc.getParent(), + imagePath); + FileInputStream imgin = new FileInputStream(imgfile); + StreamUtils.pipe(imgin, jar); + } + + } catch (Exception e) { + String errmsg = "Error adding tileset to bundle " + + "[set=" + set.getName() + ", ipath=" + imagePath + "]"; + throw (IOException)new IOException(errmsg).initCause(e); } }