2009-05-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Throw DlAbortEx instead of FatalException during parsing options
	because we don't want for aria2 to quit when bad option is passed
	via XML-RPC.
	* src/OptionHandlerException.cc
	* src/OptionHandlerException.h
	* src/OptionHandlerImpl.h
	* src/OptionParser.cc
	* src/OptionParser.h
	* src/PStringSegment.cc
	* src/ParameterizedStringParser.cc
	* src/download_helper.cc
	* test/ParameterizedStringParserTest.cc
This commit is contained in:
Tatsuhiro Tsujikawa
2009-05-12 13:51:12 +00:00
parent 2758562eb0
commit 62165b9ed1
10 changed files with 54 additions and 38 deletions

View File

@@ -8,7 +8,7 @@
#include "PStringSelect.h"
#include "PStringSegment.h"
#include "PStringNumLoop.h"
#include "FatalException.h"
#include "DlAbortEx.h"
namespace aria2 {
@@ -74,7 +74,7 @@ void ParameterizedStringParserTest::testParse_select_empty()
try {
SharedHandle<PStringDatum> ls = ParameterizedStringParser().parse("{}");
CPPUNIT_FAIL("exception must be thrown.");
} catch(FatalException& e) {
} catch(DlAbortEx& e) {
std::cerr << e.stackTrace() << std::endl;
} catch(...) {
CPPUNIT_FAIL("unexpected exception thrown.");
@@ -86,7 +86,7 @@ void ParameterizedStringParserTest::testParse_select_missingParen()
try {
SharedHandle<PStringDatum> ls = ParameterizedStringParser().parse("{alpha");
CPPUNIT_FAIL("exception must be thrown.");
} catch(FatalException& e) {
} catch(DlAbortEx& e) {
std::cerr << e.stackTrace() << std::endl;
} catch(...) {
CPPUNIT_FAIL("unexpected exception was thrown.");
@@ -141,7 +141,7 @@ void ParameterizedStringParserTest::testParse_loop_empty()
try {
SharedHandle<PStringDatum> ls = ParameterizedStringParser().parse("[]");
CPPUNIT_FAIL("exception must be thrown.");
} catch(FatalException& e) {
} catch(DlAbortEx& e) {
std::cerr << e.stackTrace() << std::endl;
} catch(...) {
CPPUNIT_FAIL("unexpected exception was thrown.");
@@ -153,7 +153,7 @@ void ParameterizedStringParserTest::testParse_loop_missingParen()
try {
SharedHandle<PStringDatum> ls = ParameterizedStringParser().parse("[");
CPPUNIT_FAIL("exception must be thrown.");
} catch(FatalException& e) {
} catch(DlAbortEx& e) {
std::cerr << e.stackTrace() << std::endl;
} catch(...) {
CPPUNIT_FAIL("unexpected exception was thrown.");
@@ -165,7 +165,7 @@ void ParameterizedStringParserTest::testParse_loop_missingStep()
try {
SharedHandle<PStringDatum> ls = ParameterizedStringParser().parse("[1-10:]");
CPPUNIT_FAIL("exception must be thrown.");
} catch(FatalException& e) {
} catch(DlAbortEx& e) {
std::cerr << e.stackTrace() << std::endl;
} catch(...) {
CPPUNIT_FAIL("unexpected exception was thrown.");
@@ -177,7 +177,7 @@ void ParameterizedStringParserTest::testParse_loop_missingRange()
try {
SharedHandle<PStringDatum> ls = ParameterizedStringParser().parse("[1-]");
CPPUNIT_FAIL("exception must be thrown.");
} catch(FatalException& e) {
} catch(DlAbortEx& e) {
std::cerr << e.stackTrace() << std::endl;
} catch(...) {
CPPUNIT_FAIL("unexpected exception was thrown.");
@@ -200,10 +200,10 @@ void ParameterizedStringParserTest::testParse_loop_mixedChar()
try {
ParameterizedStringParser().parse("[1-z:2]");
CPPUNIT_FAIL("exception must be thrown.");
} catch(FatalException& e) {
} catch(DlAbortEx& e) {
std::cerr << e.stackTrace() << std::endl;
} catch(...) {
CPPUNIT_FAIL("FatalException must be thrown.");
CPPUNIT_FAIL("DlAbortEx must be thrown.");
}
}
@@ -212,10 +212,10 @@ void ParameterizedStringParserTest::testParse_loop_mixedCase()
try {
ParameterizedStringParser().parse("[a-Z:2]");
CPPUNIT_FAIL("exception must be thrown.");
} catch(FatalException& e) {
} catch(DlAbortEx& e) {
std::cerr << e.stackTrace() << std::endl;
} catch(...) {
CPPUNIT_FAIL("FatalException must be thrown.");
CPPUNIT_FAIL("DlAbortEx must be thrown.");
}
}