mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-11 00:40:08 +00:00
Move "AseException" to "base::Exception" class.
+ Created XmlException for tinyxml parsing errors. + Moved functionality of AseException::show() to Console::showException().
This commit is contained in:
parent
cf2f042cbf
commit
45855b88d3
@ -69,7 +69,6 @@ add_subdirectory(gui)
|
||||
|
||||
add_library(aseprite-library
|
||||
app.cpp
|
||||
ase_exception.cpp
|
||||
check_args.cpp
|
||||
console.cpp
|
||||
context.cpp
|
||||
@ -82,6 +81,7 @@ add_library(aseprite-library
|
||||
resource_finder.cpp
|
||||
ui_context.cpp
|
||||
undoable.cpp
|
||||
xml_exception.cpp
|
||||
xml_widgets.cpp
|
||||
app/color.cpp
|
||||
app/color_utils.cpp
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "app.h"
|
||||
#include "app/color_utils.h"
|
||||
#include "ase_exception.h"
|
||||
#include "base/exception.h"
|
||||
#include "check_args.h"
|
||||
#include "commands/commands.h"
|
||||
#include "commands/params.h"
|
||||
@ -146,8 +146,8 @@ App::App(int argc, char* argv[])
|
||||
|
||||
std::auto_ptr<Palette> pal(Palette::load(palette_filename));
|
||||
if (pal.get() == NULL)
|
||||
throw AseException("Error loading default palette from: %s",
|
||||
static_cast<const char*>(palette_filename));
|
||||
throw base::Exception("Error loading default palette from: %s",
|
||||
static_cast<const char*>(palette_filename));
|
||||
|
||||
set_default_palette(pal.get());
|
||||
}
|
||||
|
@ -1,88 +0,0 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2011 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <allegro/unicode.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ase_exception.h"
|
||||
#include "console.h"
|
||||
#include "tinyxml.h"
|
||||
|
||||
AseException::AseException(const char* msg, ...) throw()
|
||||
{
|
||||
try {
|
||||
if (!ustrchr(msg, '%')) {
|
||||
m_msg = msg;
|
||||
}
|
||||
else {
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
|
||||
char buf[1024]; // TODO warning buffer overflow
|
||||
uvsprintf(buf, msg, ap);
|
||||
m_msg = buf;
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
// no throw
|
||||
}
|
||||
}
|
||||
|
||||
AseException::AseException(const std::string& msg) throw()
|
||||
{
|
||||
try {
|
||||
m_msg = msg;
|
||||
}
|
||||
catch (...) {
|
||||
// no throw
|
||||
}
|
||||
}
|
||||
|
||||
AseException::AseException(TiXmlDocument* doc) throw()
|
||||
{
|
||||
try {
|
||||
char buf[1024];
|
||||
usprintf(buf, "Error in XML file '%s' (line %d, column %d)\nError %d: %s",
|
||||
doc->Value(), doc->ErrorRow(), doc->ErrorCol(),
|
||||
doc->ErrorId(), doc->ErrorDesc());
|
||||
|
||||
m_msg = buf;
|
||||
}
|
||||
catch (...) {
|
||||
// no throw
|
||||
}
|
||||
}
|
||||
|
||||
AseException::~AseException() throw()
|
||||
{
|
||||
}
|
||||
|
||||
void AseException::show()
|
||||
{
|
||||
Console console;
|
||||
console.printf("A problem has occurred.\n\nDetails:\n%s", what());
|
||||
}
|
||||
|
||||
const char* AseException::what() const throw()
|
||||
{
|
||||
return m_msg.c_str();
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
add_library(base-lib
|
||||
convert_to.cpp
|
||||
errno_string.cpp
|
||||
exception.cpp
|
||||
mem_utils.cpp
|
||||
mutex.cpp
|
||||
path.cpp
|
||||
|
70
src/base/exception.cpp
Normal file
70
src/base/exception.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
// ASE base library
|
||||
// Copyright (C) 2001-2011 David Capello
|
||||
//
|
||||
// This source file is ditributed under a BSD-like license, please
|
||||
// read LICENSE.txt for more information.
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "base/exception.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
using namespace std;
|
||||
using namespace base;
|
||||
|
||||
Exception::Exception() throw()
|
||||
{
|
||||
}
|
||||
|
||||
Exception::Exception(const char* format, ...) throw()
|
||||
{
|
||||
try {
|
||||
if (!strchr(format, '%')) {
|
||||
m_msg = format;
|
||||
}
|
||||
else {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
char buf[1024]; // TODO warning buffer overflow
|
||||
vsprintf(buf, format, ap);
|
||||
m_msg = buf;
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
// No throw
|
||||
}
|
||||
}
|
||||
|
||||
Exception::Exception(const std::string& msg) throw()
|
||||
{
|
||||
try {
|
||||
m_msg = msg;
|
||||
}
|
||||
catch (...) {
|
||||
// No throw
|
||||
}
|
||||
}
|
||||
|
||||
Exception::~Exception() throw()
|
||||
{
|
||||
}
|
||||
|
||||
void Exception::setMessage(const char* msg) throw()
|
||||
{
|
||||
try {
|
||||
m_msg = msg;
|
||||
}
|
||||
catch (...) {
|
||||
// No throw
|
||||
}
|
||||
}
|
||||
|
||||
const char* Exception::what() const throw()
|
||||
{
|
||||
return m_msg.c_str();
|
||||
}
|
34
src/base/exception.h
Normal file
34
src/base/exception.h
Normal file
@ -0,0 +1,34 @@
|
||||
// ASE base library
|
||||
// Copyright (C) 2001-2011 David Capello
|
||||
//
|
||||
// This source file is ditributed under a BSD-like license, please
|
||||
// read LICENSE.txt for more information.
|
||||
|
||||
#ifndef BASE_EXCEPTION_H_INCLUDED
|
||||
#define BASE_EXCEPTION_H_INCLUDED
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
namespace base {
|
||||
|
||||
class Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
Exception() throw();
|
||||
Exception(const char* format, ...) throw();
|
||||
Exception(const std::string& msg) throw();
|
||||
virtual ~Exception() throw();
|
||||
|
||||
const char* what() const throw();
|
||||
|
||||
protected:
|
||||
void setMessage(const char* msg) throw();
|
||||
|
||||
private:
|
||||
std::string m_msg;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -20,13 +20,13 @@
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "gui/jinete.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "base/bind.h"
|
||||
#include "commands/command.h"
|
||||
#include "commands/commands.h"
|
||||
#include "console.h"
|
||||
#include "gfx/size.h"
|
||||
#include "gui/jinete.h"
|
||||
#include "modules/editors.h"
|
||||
#include "modules/gfx.h"
|
||||
#include "modules/gui.h"
|
||||
@ -543,7 +543,7 @@ void ConfigureTools::onSetGridClick()
|
||||
}
|
||||
}
|
||||
catch (LockedSpriteException& e) {
|
||||
e.show();
|
||||
Console::showException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,8 +80,8 @@ void LoadMaskCommand::onExecute(Context* context)
|
||||
|
||||
Mask *mask = load_msk_file(m_filename.c_str());
|
||||
if (!mask)
|
||||
throw AseException("Error loading .msk file: %s",
|
||||
static_cast<const char*>(m_filename.c_str()));
|
||||
throw base::Exception("Error loading .msk file: %s",
|
||||
static_cast<const char*>(m_filename.c_str()));
|
||||
|
||||
// undo
|
||||
if (sprite->getUndo()->isEnabled()) {
|
||||
|
@ -23,18 +23,18 @@
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "gui/jinete.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "app/color.h"
|
||||
#include "base/bind.h"
|
||||
#include "commands/command.h"
|
||||
#include "commands/params.h"
|
||||
#include "console.h"
|
||||
#include "core/cfg.h"
|
||||
#include "dialogs/filesel.h"
|
||||
#include "gfx/hsv.h"
|
||||
#include "gfx/rgb.h"
|
||||
#include "gfx/size.h"
|
||||
#include "gui/jinete.h"
|
||||
#include "modules/editors.h"
|
||||
#include "modules/gui.h"
|
||||
#include "modules/palettes.h"
|
||||
@ -547,8 +547,8 @@ static void sort_command(JWidget widget)
|
||||
delete palette;
|
||||
}
|
||||
}
|
||||
catch (AseException& e) {
|
||||
e.show();
|
||||
catch (base::Exception& e) {
|
||||
Console::showException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -923,8 +923,8 @@ static void update_current_sprite_palette(const char* operationName)
|
||||
sprite->setPalette(newPalette, false);
|
||||
}
|
||||
}
|
||||
catch (AseException& e) {
|
||||
e.show();
|
||||
catch (base::Exception& e) {
|
||||
Console::showException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,3 +155,10 @@ void Console::printf(const char *format, ...)
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void Console::showException(std::exception& e)
|
||||
{
|
||||
Console console;
|
||||
console.printf("A problem has occurred.\n\nDetails:\n%s", e.what());
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef CONSOLE_H_INCLUDED
|
||||
#define CONSOLE_H_INCLUDED
|
||||
|
||||
#include <exception>
|
||||
|
||||
class Console
|
||||
{
|
||||
public:
|
||||
@ -26,6 +28,8 @@ public:
|
||||
~Console();
|
||||
|
||||
void printf(const char *format, ...);
|
||||
|
||||
static void showException(std::exception& e);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -139,11 +139,11 @@ void Context::executeCommand(Command* command, Params* params)
|
||||
if (command->isEnabled(this))
|
||||
command->execute(this);
|
||||
}
|
||||
catch (AseException& e) {
|
||||
PRINTF("AseException caught executing '%s' command\n%s\n",
|
||||
catch (base::Exception& e) {
|
||||
PRINTF("Exception caught executing '%s' command\n%s\n",
|
||||
command->short_name(), e.what());
|
||||
|
||||
e.show();
|
||||
Console::showException(e);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
PRINTF("std::exception caught executing '%s' command\n%s\n",
|
||||
|
@ -20,8 +20,8 @@
|
||||
#define CONTEXT_H_INCLUDED
|
||||
|
||||
#include <list>
|
||||
#include "ase_exception.h"
|
||||
#include "base/disable_copying.h"
|
||||
#include "base/exception.h"
|
||||
#include "settings/settings.h"
|
||||
|
||||
class Sprite;
|
||||
@ -31,11 +31,11 @@ class Params;
|
||||
|
||||
typedef std::list<Sprite*> SpriteList;
|
||||
|
||||
class CommandPreconditionException : public AseException
|
||||
class CommandPreconditionException : public base::Exception
|
||||
{
|
||||
public:
|
||||
CommandPreconditionException() throw()
|
||||
: AseException("Cannot execute the command because its pre-conditions are false.") { }
|
||||
: base::Exception("Cannot execute the command because its pre-conditions are false.") { }
|
||||
};
|
||||
|
||||
class Context
|
||||
|
@ -60,8 +60,8 @@ LegacyModules::LegacyModules(int requirements)
|
||||
PRINTF("Installing module: %s\n", module[c].name);
|
||||
|
||||
if ((*module[c].init)() < 0)
|
||||
throw AseException("Error initializing module: %s",
|
||||
static_cast<const char*>(module[c].name));
|
||||
throw base::Exception("Error initializing module: %s",
|
||||
static_cast<const char*>(module[c].name));
|
||||
|
||||
module[c].installed = true;
|
||||
}
|
||||
|
@ -20,23 +20,22 @@
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
#include "gfx/rect.h"
|
||||
#include "gfx/point.h"
|
||||
|
||||
#include "commands/commands.h"
|
||||
#include "commands/command.h"
|
||||
#include "commands/commands.h"
|
||||
#include "console.h"
|
||||
#include "gfx/point.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "gui/jinete.h"
|
||||
#include "modules/gfx.h"
|
||||
#include "modules/gui.h"
|
||||
#include "modules/skinneable_theme.h"
|
||||
#include "modules/rootmenu.h"
|
||||
#include "modules/skinneable_theme.h"
|
||||
#include "raster/raster.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "ui_context.h"
|
||||
#include "undoable.h"
|
||||
#include "util/celmove.h"
|
||||
#include "util/thmbnail.h"
|
||||
#include "sprite_wrappers.h"
|
||||
#include "ui_context.h"
|
||||
|
||||
using namespace gfx;
|
||||
|
||||
@ -591,7 +590,7 @@ static bool anieditor_msg_proc(JWidget widget, JMessage msg)
|
||||
sprite_writer->setCurrentLayer(anieditor->layers[anieditor->clk_layer]);
|
||||
}
|
||||
catch (LockedSpriteException& e) {
|
||||
e.show();
|
||||
Console::showException(e);
|
||||
}
|
||||
|
||||
jwidget_dirty(widget);
|
||||
|
@ -46,33 +46,33 @@ class Sprite;
|
||||
TARGET_GRAY_CHANNEL )
|
||||
|
||||
|
||||
class invalid_effect_exception : public AseException
|
||||
class invalid_effect_exception : public base::Exception
|
||||
{
|
||||
public:
|
||||
invalid_effect_exception(const char* effect_name) throw()
|
||||
: AseException("Invalid effect specified: %s", effect_name) { }
|
||||
: base::Exception("Invalid effect specified: %s", effect_name) { }
|
||||
};
|
||||
|
||||
class invalid_imgtype_exception : public AseException
|
||||
class invalid_imgtype_exception : public base::Exception
|
||||
{
|
||||
public:
|
||||
invalid_imgtype_exception() throw()
|
||||
: AseException("Invalid image type specified.") { }
|
||||
: base::Exception("Invalid image type specified.") { }
|
||||
};
|
||||
|
||||
class invalid_area_exception : public AseException
|
||||
class invalid_area_exception : public base::Exception
|
||||
{
|
||||
public:
|
||||
invalid_area_exception() throw()
|
||||
: AseException("The current mask/area to apply the effect is completelly invalid.") { }
|
||||
: base::Exception("The current mask/area to apply the effect is completelly invalid.") { }
|
||||
};
|
||||
|
||||
class no_image_exception : public AseException
|
||||
class no_image_exception : public base::Exception
|
||||
{
|
||||
public:
|
||||
no_image_exception() throw()
|
||||
: AseException("There are not an active image to apply the effect.\n"
|
||||
"Please select a layer/cel with an image and try again.") { }
|
||||
: base::Exception("There are not an active image to apply the effect.\n"
|
||||
"Please select a layer/cel with an image and try again.") { }
|
||||
};
|
||||
|
||||
struct EffectData;
|
||||
|
@ -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 AseException("ZLib error %d in inflateInit().", err);
|
||||
throw base::Exception("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 AseException("ZLib error %d in inflate().", err);
|
||||
throw base::Exception("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 AseException("Bad compressed image.");
|
||||
throw base::Exception("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 AseException("ZLib error %d in inflateEnd().", err);
|
||||
throw base::Exception("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 AseException("ZLib error %d in deflateInit().", err);
|
||||
throw base::Exception("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 AseException("ZLib error %d in deflate().", err);
|
||||
throw base::Exception("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 AseException("Error writing compressed image pixels.\n");
|
||||
throw base::Exception("Error writing compressed image pixels.\n");
|
||||
}
|
||||
} while (zstream.avail_out == 0);
|
||||
}
|
||||
|
||||
err = deflateEnd(&zstream);
|
||||
if (err != Z_OK)
|
||||
throw AseException("ZLib error %d in deflateEnd().", err);
|
||||
throw base::Exception("ZLib error %d in deflateEnd().", err);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -140,13 +140,13 @@ bool GifFormat::onLoad(FileOp* fop)
|
||||
int frame_delay = -1;
|
||||
do {
|
||||
if (DGifGetRecordType(gif_file, &record_type) == GIF_ERROR)
|
||||
throw AseException("Invalid GIF record in file.\n");
|
||||
throw base::Exception("Invalid GIF record in file.\n");
|
||||
|
||||
switch (record_type) {
|
||||
|
||||
case IMAGE_DESC_RECORD_TYPE: {
|
||||
if (DGifGetImageDesc(gif_file) == GIF_ERROR)
|
||||
throw AseException("Invalid GIF image descriptor.\n");
|
||||
throw base::Exception("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 AseException("Image %d is out of sprite bounds.\n", frame_num);
|
||||
throw base::Exception("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 AseException("Invalid interlaced image data.");
|
||||
throw base::Exception("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 AseException("Invalid image data (%d).\n", GifLastError());
|
||||
throw base::Exception("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 AseException("Invalid GIF extension record.\n");
|
||||
throw base::Exception("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 AseException("Invalid GIF extension record.\n");
|
||||
throw base::Exception("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 AseException("Error creating GIF file.\n");
|
||||
throw base::Exception("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 AseException("Error writing GIF header.\n");
|
||||
throw base::Exception("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 AseException("Error writing GIF graphics extension record for frame %d.\n", frame_num);
|
||||
throw base::Exception("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 AseException("Error writing GIF graphics extension record for frame %d.\n", frame_num);
|
||||
throw base::Exception("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 AseException("Error writing GIF graphics extension record for frame %d.\n", frame_num);
|
||||
throw base::Exception("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 AseException("Error writing GIF graphics extension record for frame %d.\n", frame_num);
|
||||
throw base::Exception("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 AseException("Error writing GIF frame %d.\n", frame_num);
|
||||
throw base::Exception("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 AseException("Error writing GIF image scanlines for frame %d.\n", frame_num);
|
||||
throw base::Exception("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 AseException("Error writing GIF image scanlines for frame %d.\n", frame_num);
|
||||
throw base::Exception("Error writing GIF image scanlines for frame %d.\n", frame_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,13 +22,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "console.h"
|
||||
#include "core/cfg.h"
|
||||
#include "file/file.h"
|
||||
#include "file/file_format.h"
|
||||
#include "file/format_options.h"
|
||||
#include "gui/jinete.h"
|
||||
#include "modules/gui.h"
|
||||
#include "raster/raster.h"
|
||||
|
||||
@ -396,10 +396,10 @@ FormatOptions* JpegFormat::onGetFormatOptions(FileOp* fop)
|
||||
|
||||
return jpeg_options;
|
||||
}
|
||||
catch (AseException& e) {
|
||||
catch (base::Exception& e) {
|
||||
delete jpeg_options;
|
||||
|
||||
e.show();
|
||||
Console::showException(e);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
#include <allegro/file.h>
|
||||
|
||||
#include "ase_exception.h"
|
||||
#include "gui_xml.h"
|
||||
#include "resource_finder.h"
|
||||
#include "xml_exception.h"
|
||||
|
||||
// static
|
||||
GuiXml* GuiXml::instance()
|
||||
@ -52,13 +52,13 @@ GuiXml::GuiXml()
|
||||
|
||||
// Try to load the XML file
|
||||
if (!m_doc.LoadFile(path))
|
||||
throw AseException(&m_doc);
|
||||
throw XmlException(&m_doc);
|
||||
|
||||
// Done, we load the file successfully.
|
||||
return;
|
||||
}
|
||||
|
||||
throw AseException("gui.xml was not found");
|
||||
throw base::Exception("gui.xml was not found");
|
||||
}
|
||||
|
||||
TiXmlDocument& GuiXml::doc()
|
||||
|
@ -19,10 +19,10 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <allegro.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ase_exception.h"
|
||||
#include "base/exception.h"
|
||||
#include "app.h"
|
||||
#include "console.h"
|
||||
#include "loadpng.h"
|
||||
|
||||
#ifdef WIN32
|
||||
@ -71,8 +71,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
status = app.run();
|
||||
}
|
||||
catch (AseException& e) {
|
||||
e.show();
|
||||
catch (base::Exception& e) {
|
||||
Console::showException(e);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
allegro_message("%s", e.what());
|
||||
|
@ -201,11 +201,11 @@ int init_module_gui()
|
||||
|
||||
/* install the mouse */
|
||||
if (install_mouse() < 0)
|
||||
throw AseException("Error installing mouse handler");
|
||||
throw base::Exception("Error installing mouse handler");
|
||||
|
||||
/* install the keyboard */
|
||||
if (install_keyboard() < 0)
|
||||
throw AseException("Error installing keyboard handler");
|
||||
throw base::Exception("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 AseException("You cannot use ASE in 8 bits per pixel");
|
||||
throw base::Exception("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 AseException("Error setting graphics mode\n%s\n"
|
||||
"Try \"ase -res WIDTHxHEIGHTxBPP\"\n", allegro_error);
|
||||
throw base::Exception("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]) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include "ase_exception.h"
|
||||
#include "base/exception.h"
|
||||
#include "gui/jbase.h"
|
||||
#include "gui/jaccel.h"
|
||||
|
||||
@ -36,22 +36,22 @@ class CheckBox;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
class widget_file_not_found : public AseException
|
||||
class widget_file_not_found : public base::Exception
|
||||
{
|
||||
public:
|
||||
widget_file_not_found(const char* file_name) throw()
|
||||
: AseException("Cannot load file: %s\nPlease reinstall %s", file_name, PACKAGE) { }
|
||||
: base::Exception("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 AseException
|
||||
class widget_not_found : public base::Exception
|
||||
{
|
||||
public:
|
||||
widget_not_found(const char* widget_name) throw()
|
||||
: AseException("A data file is corrupted.\nPlease reinstall %s\n\n"
|
||||
"Details: Widget not found: %s", PACKAGE, widget_name) { }
|
||||
: base::Exception("A data file is corrupted.\nPlease reinstall %s\n\n"
|
||||
"Details: Widget not found: %s", PACKAGE, widget_name) { }
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -110,8 +110,8 @@ static int load_root_menu()
|
||||
|
||||
root_menu = load_menu_by_id(handle, "main_menu");
|
||||
if (!root_menu)
|
||||
throw AseException("Error loading main menu from file:\n%s\nReinstall the application.",
|
||||
static_cast<const char*>(path));
|
||||
throw base::Exception("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 AseException("Error converting the element \"%s\" to a menu-item.\n",
|
||||
static_cast<const char*>(child->Value()));
|
||||
throw base::Exception("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 AseException("Error reading the sub-menu\n");
|
||||
throw base::Exception("Error reading the sub-menu\n");
|
||||
|
||||
jmenuitem_set_submenu(menuitem, sub_menu);
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <allegro.h>
|
||||
#include <allegro/internal/aintern.h>
|
||||
|
||||
#include "ase_exception.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/shared_ptr.h"
|
||||
#include "gui/jinete.h"
|
||||
@ -30,6 +29,7 @@
|
||||
#include "modules/gui.h"
|
||||
#include "modules/skinneable_theme.h"
|
||||
#include "resource_finder.h"
|
||||
#include "xml_exception.h"
|
||||
|
||||
#include "tinyxml.h"
|
||||
|
||||
@ -182,7 +182,7 @@ void SkinneableTheme::reload_skin()
|
||||
}
|
||||
}
|
||||
if (!m_sheet_bmp)
|
||||
throw AseException("Error loading %s file", sheet_filename.c_str());
|
||||
throw base::Exception("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 AseException(&doc);
|
||||
throw XmlException(&doc);
|
||||
|
||||
TiXmlHandle handle(&doc);
|
||||
|
||||
@ -243,8 +243,8 @@ void SkinneableTheme::regen()
|
||||
}
|
||||
|
||||
if (c == JI_CURSORS) {
|
||||
throw AseException("Unknown cursor specified in '%s':\n"
|
||||
"<cursor id='%s' ... />\n", xml_filename.c_str(), id.c_str());
|
||||
throw base::Exception("Unknown cursor specified in '%s':\n"
|
||||
"<cursor id='%s' ... />\n", xml_filename.c_str(), id.c_str());
|
||||
}
|
||||
|
||||
xmlCursor = xmlCursor->NextSiblingElement();
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "base/remove_from_container.h"
|
||||
#include "base/scoped_lock.h"
|
||||
#include "file/format_options.h"
|
||||
#include "gui/jbase.h"
|
||||
#include "raster/raster.h"
|
||||
#include "util/boundary.h"
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <stdio.h>
|
||||
#include <allegro/config.h>
|
||||
|
||||
#include "gui/jbase.h"
|
||||
#include "raster/cel.h"
|
||||
#include "raster/dirty.h"
|
||||
#include "raster/image.h"
|
||||
@ -1924,7 +1925,7 @@ static UndoChunk* undo_chunk_new(UndoStream* stream, int type, int size)
|
||||
|
||||
ASSERT(size >= (int)sizeof(UndoChunk));
|
||||
|
||||
chunk = (UndoChunk* )jmalloc0(size);
|
||||
chunk = (UndoChunk*)jmalloc0(size);
|
||||
if (!chunk)
|
||||
return NULL;
|
||||
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/exception.h"
|
||||
#include "raster/gfxobj.h"
|
||||
#include "ase_exception.h"
|
||||
|
||||
class Cel;
|
||||
class Dirty;
|
||||
@ -34,10 +34,10 @@ class Sprite;
|
||||
class Stock;
|
||||
class UndoStream;
|
||||
|
||||
class UndoException : public AseException
|
||||
class UndoException : public base::Exception
|
||||
{
|
||||
public:
|
||||
UndoException(const char* msg) throw() : AseException(msg) { }
|
||||
UndoException(const char* msg) throw() : base::Exception(msg) { }
|
||||
};
|
||||
|
||||
class Undo : public GfxObj
|
||||
|
@ -21,17 +21,17 @@
|
||||
|
||||
#include <list>
|
||||
#include <exception>
|
||||
#include "ase_exception.h"
|
||||
#include "base/exception.h"
|
||||
#include "context.h"
|
||||
#include "raster/sprite.h"
|
||||
|
||||
class LockedSpriteException : public AseException
|
||||
class LockedSpriteException : public base::Exception
|
||||
{
|
||||
public:
|
||||
LockedSpriteException() throw()
|
||||
: AseException("Cannot read/write the sprite.\n"
|
||||
"The sprite is locked by a background task.\n"
|
||||
"Try again later.") { }
|
||||
: base::Exception("Cannot read/write the sprite.\n"
|
||||
"The sprite is locked by a background task.\n"
|
||||
"Try again later.") { }
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <allegro/fixed.h>
|
||||
#include <allegro/fmaths.h>
|
||||
|
||||
#include "ase_exception.h"
|
||||
#include "base/exception.h"
|
||||
#include "gui_xml.h"
|
||||
#include "raster/algo.h"
|
||||
#include "raster/image.h"
|
||||
@ -132,7 +132,7 @@ void ToolBox::loadTools()
|
||||
PRINTF(" - New group '%s'\n", group_id);
|
||||
|
||||
if (!group_id || !group_text)
|
||||
throw AseException("The configuration file has a <group> without 'id' or 'text' attributes.");
|
||||
throw base::Exception("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 AseException("Invalid fill '%s' specified in '%s' tool.\n", fill, tool_id);
|
||||
throw base::Exception("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 AseException("Invalid ink '%s' specified in '%s' tool.\n", ink, tool_id);
|
||||
throw base::Exception("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 AseException("Invalid controller '%s' specified in '%s' tool.\n", controller, tool_id);
|
||||
throw base::Exception("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 AseException("Invalid point-shape '%s' specified in '%s' tool.\n", pointshape, tool_id);
|
||||
throw base::Exception("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 AseException("Invalid intertwiner '%s' specified in '%s' tool.\n", intertwine, tool_id);
|
||||
throw base::Exception("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 AseException("Invalid trace-policy '%s' specified in '%s' tool.\n", tracepolicy, tool_id);
|
||||
throw base::Exception("Invalid trace-policy '%s' specified in '%s' tool.\n", tracepolicy, tool_id);
|
||||
}
|
||||
|
||||
// Setup the tool properties
|
||||
|
40
src/xml_exception.cpp
Normal file
40
src/xml_exception.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2011 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "tinyxml.h"
|
||||
#include "xml_exception.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
XmlException::XmlException(TiXmlDocument* doc) throw()
|
||||
{
|
||||
try {
|
||||
char buf[4096]; // TODO Overflow
|
||||
|
||||
sprintf(buf, "Error in XML file '%s' (line %d, column %d)\nError %d: %s",
|
||||
doc->Value(), doc->ErrorRow(), doc->ErrorCol(),
|
||||
doc->ErrorId(), doc->ErrorDesc());
|
||||
|
||||
setMessage(buf);
|
||||
}
|
||||
catch (...) {
|
||||
// No throw
|
||||
}
|
||||
}
|
@ -1,44 +1,32 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2011 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef ASE_EXCEPTION_H_INCLUDED
|
||||
#define ASE_EXCEPTION_H_INCLUDED
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include "gui/jbase.h"
|
||||
|
||||
class TiXmlDocument;
|
||||
|
||||
class AseException : public std::exception
|
||||
{
|
||||
public:
|
||||
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();
|
||||
|
||||
private:
|
||||
std::string m_msg;
|
||||
};
|
||||
|
||||
#endif
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2011 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef XML_EXCEPTION_H_INCLUDED
|
||||
#define XML_EXCEPTION_H_INCLUDED
|
||||
|
||||
#include "base/exception.h"
|
||||
|
||||
class TiXmlDocument;
|
||||
|
||||
class XmlException : public base::Exception
|
||||
{
|
||||
public:
|
||||
XmlException(TiXmlDocument* doc) throw();
|
||||
};
|
||||
|
||||
#endif
|
@ -24,10 +24,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ase_exception.h"
|
||||
#include "base/bind.h"
|
||||
#include "gui/jinete.h"
|
||||
#include "modules/gui.h"
|
||||
#include "xml_exception.h"
|
||||
|
||||
#include "tinyxml.h"
|
||||
|
||||
@ -49,7 +49,7 @@ Widget* load_widget_from_xmlfile(const char* xmlFilename, const char* widgetName
|
||||
|
||||
TiXmlDocument doc;
|
||||
if (!doc.LoadFile(xmlFilename))
|
||||
throw AseException(&doc);
|
||||
throw XmlException(&doc);
|
||||
|
||||
// search the requested widget
|
||||
TiXmlHandle handle(&doc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user