Rename ase_exception to AseException.

This commit is contained in:
David Capello 2011-01-20 18:03:11 -03:00
parent 610e06931b
commit e914c9ad6a
22 changed files with 94 additions and 94 deletions

View File

@ -146,8 +146,8 @@ App::App(int argc, char* argv[])
std::auto_ptr<Palette> pal(Palette::load(palette_filename));
if (pal.get() == NULL)
throw ase_exception("Error loading default palette from: %s",
static_cast<const char*>(palette_filename));
throw AseException("Error loading default palette from: %s",
static_cast<const char*>(palette_filename));
set_default_palette(pal.get());
}

View File

@ -25,7 +25,7 @@
#include "console.h"
#include "tinyxml.h"
ase_exception::ase_exception(const char* msg, ...) throw()
AseException::AseException(const char* msg, ...) throw()
{
try {
if (!ustrchr(msg, '%')) {
@ -47,7 +47,7 @@ ase_exception::ase_exception(const char* msg, ...) throw()
}
}
ase_exception::ase_exception(const std::string& msg) throw()
AseException::AseException(const std::string& msg) throw()
{
try {
m_msg = msg;
@ -57,7 +57,7 @@ ase_exception::ase_exception(const std::string& msg) throw()
}
}
ase_exception::ase_exception(TiXmlDocument* doc) throw()
AseException::AseException(TiXmlDocument* doc) throw()
{
try {
char buf[1024];
@ -72,17 +72,17 @@ ase_exception::ase_exception(TiXmlDocument* doc) throw()
}
}
ase_exception::~ase_exception() throw()
AseException::~AseException() throw()
{
}
void ase_exception::show()
void AseException::show()
{
Console console;
console.printf("A problem has occurred.\n\nDetails:\n%s", what());
}
const char* ase_exception::what() const throw()
const char* AseException::what() const throw()
{
return m_msg.c_str();
}

View File

@ -25,14 +25,14 @@
class TiXmlDocument;
class ase_exception : public std::exception
class AseException : public std::exception
{
public:
ase_exception() throw();
ase_exception(const char* msg, ...) throw();
ase_exception(const std::string& msg) throw();
ase_exception(TiXmlDocument* doc) throw();
virtual ~ase_exception() throw();
AseException() throw();
AseException(const char* msg, ...) throw();
AseException(const std::string& msg) throw();
AseException(TiXmlDocument* doc) throw();
virtual ~AseException() throw();
virtual void show();
const char* what() const throw();

View File

@ -80,8 +80,8 @@ void LoadMaskCommand::onExecute(Context* context)
Mask *mask = load_msk_file(m_filename.c_str());
if (!mask)
throw ase_exception("Error loading .msk file: %s",
static_cast<const char*>(m_filename.c_str()));
throw AseException("Error loading .msk file: %s",
static_cast<const char*>(m_filename.c_str()));
// undo
if (sprite->getUndo()->isEnabled()) {

View File

@ -547,7 +547,7 @@ static void sort_command(JWidget widget)
delete palette;
}
}
catch (ase_exception& e) {
catch (AseException& e) {
e.show();
}
}
@ -923,7 +923,7 @@ static void update_current_sprite_palette(const char* operationName)
sprite->setPalette(newPalette, false);
}
}
catch (ase_exception& e) {
catch (AseException& e) {
e.show();
}
}

View File

@ -142,8 +142,8 @@ void Context::execute_command(Command* command, Params* params)
if (command->isEnabled(this))
command->execute(this);
}
catch (ase_exception& e) {
PRINTF("ase_exception caught executing '%s' command\n%s\n",
catch (AseException& e) {
PRINTF("AseException caught executing '%s' command\n%s\n",
command->short_name(), e.what());
e.show();

View File

@ -31,11 +31,11 @@ class Params;
typedef std::list<Sprite*> SpriteList;
class CommandPreconditionException : public ase_exception
class CommandPreconditionException : public AseException
{
public:
CommandPreconditionException() throw()
: ase_exception("Cannot execute the command because its pre-conditions are false.") { }
: AseException("Cannot execute the command because its pre-conditions are false.") { }
};
class Context

View File

@ -60,8 +60,8 @@ LegacyModules::LegacyModules(int requirements)
PRINTF("Installing module: %s\n", module[c].name);
if ((*module[c].init)() < 0)
throw ase_exception("Error initializing module: %s",
static_cast<const char*>(module[c].name));
throw AseException("Error initializing module: %s",
static_cast<const char*>(module[c].name));
module[c].installed = true;
}

View File

@ -46,33 +46,33 @@ class Sprite;
TARGET_GRAY_CHANNEL )
class invalid_effect_exception : public ase_exception
class invalid_effect_exception : public AseException
{
public:
invalid_effect_exception(const char* effect_name) throw()
: ase_exception("Invalid effect specified: %s", effect_name) { }
: AseException("Invalid effect specified: %s", effect_name) { }
};
class invalid_imgtype_exception : public ase_exception
class invalid_imgtype_exception : public AseException
{
public:
invalid_imgtype_exception() throw()
: ase_exception("Invalid image type specified.") { }
: AseException("Invalid image type specified.") { }
};
class invalid_area_exception : public ase_exception
class invalid_area_exception : public AseException
{
public:
invalid_area_exception() throw()
: ase_exception("The current mask/area to apply the effect is completelly invalid.") { }
: AseException("The current mask/area to apply the effect is completelly invalid.") { }
};
class no_image_exception : public ase_exception
class no_image_exception : public AseException
{
public:
no_image_exception() throw()
: ase_exception("There are not an active image to apply the effect.\n"
"Please select a layer/cel with an image and try again.") { }
: AseException("There are not an active image to apply the effect.\n"
"Please select a layer/cel with an image and try again.") { }
};
struct EffectData;

View File

@ -891,7 +891,7 @@ static void read_compressed_image(FILE* f, Image* image, size_t chunk_end, FileO
err = inflateInit(&zstream);
if (err != Z_OK)
throw ase_exception("ZLib error %d in inflateInit().", err);
throw AseException("ZLib error %d in inflateInit().", err);
std::vector<ase_uint8> scanline(ImageTraits::scanline_size(image->w));
std::vector<ase_uint8> uncompressed(image->h * ImageTraits::scanline_size(image->w));
@ -922,12 +922,12 @@ static void read_compressed_image(FILE* f, Image* image, size_t chunk_end, FileO
err = inflate(&zstream, Z_NO_FLUSH);
if (err != Z_OK && err != Z_STREAM_END)
throw ase_exception("ZLib error %d in inflate().", err);
throw AseException("ZLib error %d in inflate().", err);
size_t input_bytes = scanline.size() - zstream.avail_out;
if (input_bytes > 0) {
if (uncompressed_offset+input_bytes > uncompressed.size())
throw ase_exception("Bad compressed image.");
throw AseException("Bad compressed image.");
std::copy(scanline.begin(), scanline.begin()+input_bytes,
uncompressed.begin()+uncompressed_offset);
@ -948,7 +948,7 @@ static void read_compressed_image(FILE* f, Image* image, size_t chunk_end, FileO
err = inflateEnd(&zstream);
if (err != Z_OK)
throw ase_exception("ZLib error %d in inflateEnd().", err);
throw AseException("ZLib error %d in inflateEnd().", err);
}
template<typename ImageTraits>
@ -963,7 +963,7 @@ static void write_compressed_image(FILE* f, Image* image)
zstream.opaque = (voidpf)0;
err = deflateInit(&zstream, Z_DEFAULT_COMPRESSION);
if (err != Z_OK)
throw ase_exception("ZLib error %d in deflateInit().", err);
throw AseException("ZLib error %d in deflateInit().", err);
std::vector<ase_uint8> scanline(ImageTraits::scanline_size(image->w));
std::vector<ase_uint8> compressed(4096);
@ -982,20 +982,20 @@ static void write_compressed_image(FILE* f, Image* image)
// Compress
err = deflate(&zstream, (y < image->h-1 ? Z_NO_FLUSH: Z_FINISH));
if (err != Z_OK && err != Z_STREAM_END)
throw ase_exception("ZLib error %d in deflate().", err);
throw AseException("ZLib error %d in deflate().", err);
int output_bytes = compressed.size() - zstream.avail_out;
if (output_bytes > 0) {
if ((fwrite(&compressed[0], 1, output_bytes, f) != (size_t)output_bytes)
|| ferror(f))
throw ase_exception("Error writing compressed image pixels.\n");
throw AseException("Error writing compressed image pixels.\n");
}
} while (zstream.avail_out == 0);
}
err = deflateEnd(&zstream);
if (err != Z_OK)
throw ase_exception("ZLib error %d in deflateEnd().", err);
throw AseException("ZLib error %d in deflateEnd().", err);
}
//////////////////////////////////////////////////////////////////////

View File

@ -140,13 +140,13 @@ bool GifFormat::onLoad(FileOp* fop)
int frame_delay = -1;
do {
if (DGifGetRecordType(gif_file, &record_type) == GIF_ERROR)
throw ase_exception("Invalid GIF record in file.\n");
throw AseException("Invalid GIF record in file.\n");
switch (record_type) {
case IMAGE_DESC_RECORD_TYPE: {
if (DGifGetImageDesc(gif_file) == GIF_ERROR)
throw ase_exception("Invalid GIF image descriptor.\n");
throw AseException("Invalid GIF image descriptor.\n");
// These are the bounds of the image to read.
int frame_x = gif_file->Image.Left;
@ -157,7 +157,7 @@ bool GifFormat::onLoad(FileOp* fop)
if (frame_x < 0 || frame_y < 0 ||
frame_x + frame_w > sprite_w ||
frame_y + frame_h > sprite_h)
throw ase_exception("Image %d is out of sprite bounds.\n", frame_num);
throw AseException("Image %d is out of sprite bounds.\n", frame_num);
// Add a new frame in the sprite.
sprite->setTotalFrames(frame_num+1);
@ -193,14 +193,14 @@ bool GifFormat::onLoad(FileOp* fop)
for (int y = interlaced_offset[i]; y < frame_h; y += interlaced_jumps[i]) {
addr = image_address_fast<IndexedTraits>(frame_image, 0, y);
if (DGifGetLine(gif_file, addr, frame_w) == GIF_ERROR)
throw ase_exception("Invalid interlaced image data.");
throw AseException("Invalid interlaced image data.");
}
}
else {
for (int y = 0; y < frame_h; ++y) {
addr = image_address_fast<IndexedTraits>(frame_image, 0, y);
if (DGifGetLine(gif_file, addr, frame_w) == GIF_ERROR)
throw ase_exception("Invalid image data (%d).\n", GifLastError());
throw AseException("Invalid image data (%d).\n", GifLastError());
}
}
@ -280,7 +280,7 @@ bool GifFormat::onLoad(FileOp* fop)
int ext_code;
if (DGifGetExtension(gif_file, &ext_code, &extension) == GIF_ERROR)
throw ase_exception("Invalid GIF extension record.\n");
throw AseException("Invalid GIF extension record.\n");
if (ext_code == GRAPHICS_EXT_FUNC_CODE) {
if (extension[0] >= 4) {
@ -295,7 +295,7 @@ bool GifFormat::onLoad(FileOp* fop)
while (extension != NULL) {
if (DGifGetExtensionNext(gif_file, &extension) == GIF_ERROR)
throw ase_exception("Invalid GIF extension record.\n");
throw AseException("Invalid GIF extension record.\n");
}
break;
}
@ -322,7 +322,7 @@ bool GifFormat::onSave(FileOp* fop)
{
SharedPtr<GifFileType, EGifDeleter> gif_file(EGifOpenFileName(fop->filename.c_str(), 0));
if (!gif_file)
throw ase_exception("Error creating GIF file.\n");
throw AseException("Error creating GIF file.\n");
Sprite *sprite = fop->sprite;
int sprite_w = sprite->getWidth();
@ -345,7 +345,7 @@ bool GifFormat::onSave(FileOp* fop)
if (EGifPutScreenDesc(gif_file, sprite_w, sprite_h,
color_map->BitsPerPixel,
background_color, color_map) == GIF_ERROR)
throw ase_exception("Error writing GIF header.\n");
throw AseException("Error writing GIF header.\n");
SharedPtr<Image> buffer_image;
SharedPtr<Image> current_image(image_new(IMAGE_INDEXED, sprite_w, sprite_h));
@ -431,16 +431,16 @@ bool GifFormat::onSave(FileOp* fop)
memcpy(extension_bytes, "NETSCAPE2.0", 11);
if (EGifPutExtensionFirst(gif_file, APPLICATION_EXT_FUNC_CODE, 11, extension_bytes) == GIF_ERROR)
throw ase_exception("Error writing GIF graphics extension record for frame %d.\n", frame_num);
throw AseException("Error writing GIF graphics extension record for frame %d.\n", frame_num);
extension_bytes[0] = 1;
extension_bytes[1] = (loop & 0xff);
extension_bytes[2] = (loop >> 8) & 0xff;
if (EGifPutExtensionNext(gif_file, APPLICATION_EXT_FUNC_CODE, 3, extension_bytes) == GIF_ERROR)
throw ase_exception("Error writing GIF graphics extension record for frame %d.\n", frame_num);
throw AseException("Error writing GIF graphics extension record for frame %d.\n", frame_num);
if (EGifPutExtensionLast(gif_file, APPLICATION_EXT_FUNC_CODE, 0, NULL) == GIF_ERROR)
throw ase_exception("Error writing GIF graphics extension record for frame %d.\n", frame_num);
throw AseException("Error writing GIF graphics extension record for frame %d.\n", frame_num);
}
// Write graphics extension record (to save the duration of the
@ -457,7 +457,7 @@ bool GifFormat::onSave(FileOp* fop)
extension_bytes[3] = transparent_index;
if (EGifPutExtension(gif_file, GRAPHICS_EXT_FUNC_CODE, 4, extension_bytes) == GIF_ERROR)
throw ase_exception("Error writing GIF graphics extension record for frame %d.\n", frame_num);
throw AseException("Error writing GIF graphics extension record for frame %d.\n", frame_num);
}
// Image color map
@ -477,7 +477,7 @@ bool GifFormat::onSave(FileOp* fop)
frame_x, frame_y,
frame_w, frame_h, interlace ? 1: 0,
image_color_map) == GIF_ERROR)
throw ase_exception("Error writing GIF frame %d.\n", frame_num);
throw AseException("Error writing GIF frame %d.\n", frame_num);
// Write the image data (pixels).
if (interlace) {
@ -486,7 +486,7 @@ bool GifFormat::onSave(FileOp* fop)
for (int y = interlaced_offset[i]; y < frame_h; y += interlaced_jumps[i]) {
IndexedTraits::address_t addr = image_address_fast<IndexedTraits>(current_image, frame_x, frame_y + y);
if (EGifPutLine(gif_file, addr, frame_w) == GIF_ERROR)
throw ase_exception("Error writing GIF image scanlines for frame %d.\n", frame_num);
throw AseException("Error writing GIF image scanlines for frame %d.\n", frame_num);
}
}
else {
@ -494,7 +494,7 @@ bool GifFormat::onSave(FileOp* fop)
for (int y = 0; y < frame_h; ++y) {
IndexedTraits::address_t addr = image_address_fast<IndexedTraits>(current_image, frame_x, frame_y + y);
if (EGifPutLine(gif_file, addr, frame_w) == GIF_ERROR)
throw ase_exception("Error writing GIF image scanlines for frame %d.\n", frame_num);
throw AseException("Error writing GIF image scanlines for frame %d.\n", frame_num);
}
}

View File

@ -396,7 +396,7 @@ FormatOptions* JpegFormat::onGetFormatOptions(FileOp* fop)
return jpeg_options;
}
catch (ase_exception& e) {
catch (AseException& e) {
delete jpeg_options;
e.show();

View File

@ -52,13 +52,13 @@ GuiXml::GuiXml()
// Try to load the XML file
if (!m_doc.LoadFile(path))
throw ase_exception(&m_doc);
throw AseException(&m_doc);
// Done, we load the file successfully.
return;
}
throw ase_exception("gui.xml was not found");
throw AseException("gui.xml was not found");
}
TiXmlDocument& GuiXml::doc()

View File

@ -71,7 +71,7 @@ int main(int argc, char* argv[])
status = app.run();
}
catch (ase_exception& e) {
catch (AseException& e) {
e.show();
}
catch (std::exception& e) {

View File

@ -201,11 +201,11 @@ int init_module_gui()
/* install the mouse */
if (install_mouse() < 0)
throw ase_exception("Error installing mouse handler");
throw AseException("Error installing mouse handler");
/* install the keyboard */
if (install_keyboard() < 0)
throw ase_exception("Error installing keyboard handler");
throw AseException("Error installing keyboard handler");
/* disable Ctrl+Shift+End in non-DOS */
#if !defined(ALLEGRO_DOS)
@ -262,7 +262,7 @@ int init_module_gui()
for (;;) {
if (bpp == 8)
throw ase_exception("You cannot use ASE in 8 bits per pixel");
throw AseException("You cannot use ASE in 8 bits per pixel");
// Original
set_color_depth(bpp);
@ -279,8 +279,8 @@ int init_module_gui()
}
if (bpp == 15)
throw ase_exception("Error setting graphics mode\n%s\n"
"Try \"ase -res WIDTHxHEIGHTxBPP\"\n", allegro_error);
throw AseException("Error setting graphics mode\n%s\n"
"Try \"ase -res WIDTHxHEIGHTxBPP\"\n", allegro_error);
for (c=0; try_depths[c]; ++c) {
if (bpp == try_depths[c]) {

View File

@ -36,22 +36,22 @@ class CheckBox;
//////////////////////////////////////////////////////////////////////
class widget_file_not_found : public ase_exception
class widget_file_not_found : public AseException
{
public:
widget_file_not_found(const char* file_name) throw()
: ase_exception("Cannot load file: %s\nPlease reinstall %s", file_name, PACKAGE) { }
: AseException("Cannot load file: %s\nPlease reinstall %s", file_name, PACKAGE) { }
};
/**
* Exception thrown by find_widget() if a widget is not found.
*/
class widget_not_found : public ase_exception
class widget_not_found : public AseException
{
public:
widget_not_found(const char* widget_name) throw()
: ase_exception("A data file is corrupted.\nPlease reinstall %s\n\n"
"Details: Widget not found: %s", PACKAGE, widget_name) { }
: AseException("A data file is corrupted.\nPlease reinstall %s\n\n"
"Details: Widget not found: %s", PACKAGE, widget_name) { }
};
//////////////////////////////////////////////////////////////////////

View File

@ -110,8 +110,8 @@ static int load_root_menu()
root_menu = load_menu_by_id(handle, "main_menu");
if (!root_menu)
throw ase_exception("Error loading main menu from file:\n%s\nReinstall the application.",
static_cast<const char*>(path));
throw AseException("Error loading main menu from file:\n%s\nReinstall the application.",
static_cast<const char*>(path));
PRINTF("Main menu loaded.\n");
@ -273,8 +273,8 @@ static JWidget convert_xmlelem_to_menu(TiXmlElement* elem)
if (menuitem)
jwidget_add_child(menu, menuitem);
else
throw ase_exception("Error converting the element \"%s\" to a menu-item.\n",
static_cast<const char*>(child->Value()));
throw AseException("Error converting the element \"%s\" to a menu-item.\n",
static_cast<const char*>(child->Value()));
child = child->NextSiblingElement();
}
@ -328,7 +328,7 @@ static JWidget convert_xmlelem_to_menuitem(TiXmlElement* elem)
/* create the sub-menu */
JWidget sub_menu = convert_xmlelem_to_menu(elem);
if (!sub_menu)
throw ase_exception("Error reading the sub-menu\n");
throw AseException("Error reading the sub-menu\n");
jmenuitem_set_submenu(menuitem, sub_menu);
}

View File

@ -182,7 +182,7 @@ void SkinneableTheme::reload_skin()
}
}
if (!m_sheet_bmp)
throw ase_exception("Error loading %s file", sheet_filename.c_str());
throw AseException("Error loading %s file", sheet_filename.c_str());
}
std::string SkinneableTheme::get_font_filename() const
@ -211,7 +211,7 @@ void SkinneableTheme::regen()
TiXmlDocument doc;
if (!doc.LoadFile(path))
throw ase_exception(&doc);
throw AseException(&doc);
TiXmlHandle handle(&doc);
@ -243,8 +243,8 @@ void SkinneableTheme::regen()
}
if (c == JI_CURSORS) {
throw ase_exception("Unknown cursor specified in '%s':\n"
"<cursor id='%s' ... />\n", xml_filename.c_str(), id.c_str());
throw AseException("Unknown cursor specified in '%s':\n"
"<cursor id='%s' ... />\n", xml_filename.c_str(), id.c_str());
}
xmlCursor = xmlCursor->NextSiblingElement();

View File

@ -34,10 +34,10 @@ class Sprite;
class Stock;
class UndoStream;
class UndoException : public ase_exception
class UndoException : public AseException
{
public:
UndoException(const char* msg) throw() : ase_exception(msg) { }
UndoException(const char* msg) throw() : AseException(msg) { }
};
class Undo : public GfxObj

View File

@ -25,13 +25,13 @@
#include "context.h"
#include "raster/sprite.h"
class LockedSpriteException : public ase_exception
class LockedSpriteException : public AseException
{
public:
LockedSpriteException() throw()
: ase_exception("Cannot read/write the sprite.\n"
"The sprite is locked by a background task.\n"
"Try again later.") { }
: AseException("Cannot read/write the sprite.\n"
"The sprite is locked by a background task.\n"
"Try again later.") { }
};
//////////////////////////////////////////////////////////////////////

View File

@ -132,7 +132,7 @@ void ToolBox::loadTools()
PRINTF(" - New group '%s'\n", group_id);
if (!group_id || !group_text)
throw ase_exception("The configuration file has a <group> without 'id' or 'text' attributes.");
throw AseException("The configuration file has a <group> without 'id' or 'text' attributes.");
ToolGroup* tool_group = new ToolGroup(group_id, group_text);
@ -190,32 +190,32 @@ void ToolBox::loadToolProperties(TiXmlElement* xmlTool, Tool* tool, int button,
else if (strcmp(fill, "optional") == 0)
fill_value = TOOL_FILL_OPTIONAL;
else
throw ase_exception("Invalid fill '%s' specified in '%s' tool.\n", fill, tool_id);
throw AseException("Invalid fill '%s' specified in '%s' tool.\n", fill, tool_id);
}
// Find the ink
std::map<std::string, ToolInk*>::iterator it_ink
= m_inks.find(ink ? ink: "");
if (it_ink == m_inks.end())
throw ase_exception("Invalid ink '%s' specified in '%s' tool.\n", ink, tool_id);
throw AseException("Invalid ink '%s' specified in '%s' tool.\n", ink, tool_id);
// Find the controller
std::map<std::string, ToolController*>::iterator it_controller
= m_controllers.find(controller ? controller: "none");
if (it_controller == m_controllers.end())
throw ase_exception("Invalid controller '%s' specified in '%s' tool.\n", controller, tool_id);
throw AseException("Invalid controller '%s' specified in '%s' tool.\n", controller, tool_id);
// Find the point_shape
std::map<std::string, ToolPointShape*>::iterator it_pointshaper
= m_pointshapers.find(pointshape ? pointshape: "none");
if (it_pointshaper == m_pointshapers.end())
throw ase_exception("Invalid point-shape '%s' specified in '%s' tool.\n", pointshape, tool_id);
throw AseException("Invalid point-shape '%s' specified in '%s' tool.\n", pointshape, tool_id);
// Find the intertwiner
std::map<std::string, ToolIntertwine*>::iterator it_intertwiner
= m_intertwiners.find(intertwine ? intertwine: "none");
if (it_intertwiner == m_intertwiners.end())
throw ase_exception("Invalid intertwiner '%s' specified in '%s' tool.\n", intertwine, tool_id);
throw AseException("Invalid intertwiner '%s' specified in '%s' tool.\n", intertwine, tool_id);
// Trace policy
ToolTracePolicy tracepolicy_value = TOOL_TRACE_POLICY_LAST;
@ -227,7 +227,7 @@ void ToolBox::loadToolProperties(TiXmlElement* xmlTool, Tool* tool, int button,
else if (strcmp(tracepolicy, "overlap") == 0)
tracepolicy_value = TOOL_TRACE_POLICY_OVERLAP;
else
throw ase_exception("Invalid trace-policy '%s' specified in '%s' tool.\n", tracepolicy, tool_id);
throw AseException("Invalid trace-policy '%s' specified in '%s' tool.\n", tracepolicy, tool_id);
}
// Setup the tool properties

View File

@ -49,7 +49,7 @@ Widget* load_widget_from_xmlfile(const char* xmlFilename, const char* widgetName
TiXmlDocument doc;
if (!doc.LoadFile(xmlFilename))
throw ase_exception(&doc);
throw AseException(&doc);
// search the requested widget
TiXmlHandle handle(&doc);