Commit 0821f2b7 authored by JINMEI Tatuya's avatar JINMEI Tatuya

minor cleanup:

 - catch exceptions by reference
 - and constify them

should be trivial enough, so I'm skipping explicit review.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@2728 e5f2f494-b856-4b98-b285-d166d9295462
parent c91caba6
......@@ -589,7 +589,7 @@ Rcode_init(s_Rcode* self UNUSED_PARAM, PyObject* args UNUSED_PARAM) {
try {
self->rcode = new Rcode(code);
self->static_code = false;
} catch (isc::OutOfRange) {
} catch (const isc::OutOfRange&) {
PyErr_SetString(PyExc_OverflowError,
"rcode out of range");
return (-1);
......@@ -1221,7 +1221,7 @@ Message_setHeaderFlag(s_Message* self, PyObject* args) {
try {
self->message->setHeaderFlag(*messageflag->messageflag);
Py_RETURN_NONE;
} catch (isc::dns::InvalidMessageOperation imo) {
} catch (const InvalidMessageOperation& imo) {
PyErr_Clear();
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
......@@ -1238,7 +1238,7 @@ Message_clearHeaderFlag(s_Message* self, PyObject* args) {
try {
self->message->clearHeaderFlag(*messageflag->messageflag);
Py_RETURN_NONE;
} catch (isc::dns::InvalidMessageOperation imo) {
} catch (const InvalidMessageOperation& imo) {
PyErr_Clear();
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
......@@ -1269,7 +1269,7 @@ Message_setDNSSECSupported(s_Message* self, PyObject* args) {
self->message->setDNSSECSupported(false);
}
Py_RETURN_NONE;
} catch (isc::dns::InvalidMessageOperation imo) {
} catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
......@@ -1289,10 +1289,10 @@ Message_setUDPSize(s_Message* self, PyObject* args) {
try {
self->message->setUDPSize(size);
Py_RETURN_NONE;
} catch (isc::dns::InvalidMessageUDPSize imus) {
} catch (const InvalidMessageUDPSize& imus) {
PyErr_SetString(po_InvalidMessageUDPSize, imus.what());
return (NULL);
} catch (isc::dns::InvalidMessageOperation imo) {
} catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
......@@ -1312,7 +1312,7 @@ Message_setQid(s_Message* self, PyObject* args) {
try {
self->message->setQid(id);
Py_RETURN_NONE;
} catch (InvalidMessageOperation imo) {
} catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
......@@ -1344,7 +1344,7 @@ Message_setRcode(s_Message* self, PyObject* args) {
try {
self->message->setRcode(*rcode->rcode);
Py_RETURN_NONE;
} catch (InvalidMessageOperation imo) {
} catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
......@@ -1379,7 +1379,7 @@ Message_setOpcode(s_Message* self, PyObject* args) {
try {
self->message->setOpcode(*opcode->opcode);
Py_RETURN_NONE;
} catch (InvalidMessageOperation imo) {
} catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
......@@ -1482,7 +1482,7 @@ Message_addRRset(s_Message* self, PyObject* args) {
self->message->addRRset(*section->section, rrset->rrset, false);
}
Py_RETURN_NONE;
} catch (InvalidMessageOperation imo) {
} catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
......@@ -1541,7 +1541,7 @@ Message_toWire(s_Message* self, PyObject* args) {
// If we return NULL it is seen as an error, so use this for
// None returns
Py_RETURN_NONE;
} catch (isc::dns::InvalidMessageOperation imo) {
} catch (const InvalidMessageOperation& imo) {
PyErr_Clear();
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
......@@ -1565,16 +1565,16 @@ Message_fromWire(s_Message* self, PyObject* args) {
try {
self->message->fromWire(inbuf);
Py_RETURN_NONE;
} catch (isc::dns::InvalidMessageOperation imo) {
} catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
} catch (isc::dns::DNSMessageFORMERR dmfe) {
} catch (const DNSMessageFORMERR& dmfe) {
PyErr_SetString(po_DNSMessageFORMERR, dmfe.what());
return (NULL);
} catch (isc::dns::DNSMessageBADVERS dmfe) {
} catch (const DNSMessageBADVERS& dmfe) {
PyErr_SetString(po_DNSMessageBADVERS, dmfe.what());
return (NULL);
} catch (isc::dns::MessageTooShort mts) {
} catch (const MessageTooShort& mts) {
PyErr_SetString(po_MessageTooShort, mts.what());
return (NULL);
}
......
......@@ -291,26 +291,26 @@ Name_init(s_Name* self, PyObject* args) {
self->name = new Name(n, downcase == Py_True);
self->position = 0;
} catch (EmptyLabel) {
} catch (const EmptyLabel&) {
PyErr_SetString(po_EmptyLabel, "EmptyLabel");
return (-1);
} catch (TooLongLabel) {
} catch (const TooLongLabel&) {
PyErr_SetString(po_TooLongLabel, "TooLongLabel");
return (-1);
} catch (BadLabelType) {
} catch (const BadLabelType&) {
PyErr_SetString(po_BadLabelType, "BadLabelType");
return (-1);
} catch (BadEscape) {
} catch (const BadEscape&) {
PyErr_SetString(po_BadEscape, "BadEscape");
return (-1);
} catch (TooLongName) {
} catch (const TooLongName&) {
PyErr_SetString(po_TooLongName, "TooLongName");
return (-1);
} catch (IncompleteName) {
} catch (const IncompleteName&) {
PyErr_SetString(po_IncompleteName, "IncompleteName");
return (-1);
#ifdef CATCHMEMERR
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
PyErr_NoMemory();
return (-1);
#endif
......@@ -338,11 +338,11 @@ Name_init(s_Name* self, PyObject* args) {
buffer.setPosition(position);
self->name = new Name(buffer, downcase == Py_True);
self->position = buffer.getPosition();
} catch (InvalidBufferPosition) {
} catch (const InvalidBufferPosition&) {
PyErr_SetString(po_InvalidBufferPosition,
"InvalidBufferPosition");
return (-1);
} catch (DNSMessageFORMERR) {
} catch (const DNSMessageFORMERR&) {
PyErr_SetString(po_DNSMessageFORMERR, "DNSMessageFORMERR");
return (-1);
} catch (...) {
......@@ -373,7 +373,7 @@ Name_at(s_Name* self, PyObject* args) {
}
try {
return (Py_BuildValue("I", self->name->at(pos)));
} catch (isc::OutOfRange oor) {
} catch (const isc::OutOfRange&) {
PyErr_SetString(PyExc_IndexError,
"name index out of range");
return (NULL);
......@@ -472,7 +472,7 @@ Name_split(s_Name* self, PyObject* args) {
ret->name = NULL;
try {
ret->name = new Name(self->name->split(first, n));
} catch(isc::OutOfRange oor) {
} catch(const isc::OutOfRange& oor) {
PyErr_SetString(PyExc_IndexError, oor.what());
ret->name = NULL;
}
......@@ -487,7 +487,7 @@ Name_split(s_Name* self, PyObject* args) {
ret->name = NULL;
try {
ret->name = new Name(self->name->split(n));
} catch(isc::OutOfRange oor) {
} catch(const isc::OutOfRange& oor) {
PyErr_SetString(PyExc_IndexError, oor.what());
ret->name = NULL;
}
......@@ -572,7 +572,7 @@ Name_concatenate(s_Name* self, PyObject* args) {
if (ret != NULL) {
try {
ret->name = new Name(self->name->concatenate(*other->name));
} catch (isc::dns::TooLongName tln) {
} catch (const TooLongName& tln) {
PyErr_SetString(po_TooLongName, tln.what());
return (NULL);
}
......
......@@ -156,15 +156,15 @@ Question_init(s_Question* self, PyObject* args) {
self->question = QuestionPtr(new Question(inbuf));
return (0);
}
} catch (isc::dns::DNSMessageFORMERR dmfe) {
} catch (const DNSMessageFORMERR& dmfe) {
PyErr_Clear();
PyErr_SetString(po_DNSMessageFORMERR, dmfe.what());
return (-1);
} catch (isc::dns::IncompleteRRClass irc) {
} catch (const IncompleteRRClass& irc) {
PyErr_Clear();
PyErr_SetString(po_IncompleteRRClass, irc.what());
return (-1);
} catch (isc::dns::IncompleteRRType irt) {
} catch (const IncompleteRRType& irt) {
PyErr_Clear();
PyErr_SetString(po_IncompleteRRType, irt.what());
return (-1);
......
......@@ -188,7 +188,7 @@ RRClass_init(s_RRClass* self, PyObject* args) {
}
// Incomplete is never thrown, a type error would have already been raised
//when we try to read the 2 bytes above
} catch (InvalidRRClass ic) {
} catch (const InvalidRRClass& ic) {
PyErr_Clear();
PyErr_SetString(po_InvalidRRClass, ic.what());
return (-1);
......
......@@ -284,7 +284,7 @@ static PyObject*
RRset_toText(s_RRset* self) {
try {
return (Py_BuildValue("s", self->rrset->toText().c_str()));
} catch (EmptyRRset ers) {
} catch (const EmptyRRset& ers) {
PyErr_SetString(po_EmptyRRset, ers.what());
return (NULL);
}
......@@ -321,7 +321,7 @@ RRset_toWire(s_RRset* self, PyObject* args) {
// None returns
Py_RETURN_NONE;
}
} catch (EmptyRRset ers) {
} catch (const EmptyRRset& ers) {
PyErr_Clear();
PyErr_SetString(po_EmptyRRset, ers.what());
return (NULL);
......@@ -341,7 +341,7 @@ RRset_addRdata(s_RRset* self, PyObject* args) {
try {
self->rrset->addRdata(*rdata->rdata);
Py_RETURN_NONE;
} catch (std::bad_cast) {
} catch (const std::bad_cast&) {
PyErr_Clear();
PyErr_SetString(PyExc_TypeError,
"Rdata type to add must match type of RRset");
......
......@@ -177,7 +177,7 @@ RRTTL_init(s_RRTTL* self, PyObject* args) {
PyErr_Clear();
return (0);
}
} catch (IncompleteRRTTL icc) {
} catch (const IncompleteRRTTL& icc) {
// Ok so one of our functions has thrown a C++ exception.
// We need to translate that to a Python Exception
// First clear any existing error that was set
......@@ -186,7 +186,7 @@ RRTTL_init(s_RRTTL* self, PyObject* args) {
PyErr_SetString(po_IncompleteRRTTL, icc.what());
// And return negative
return (-1);
} catch (InvalidRRTTL ic) {
} catch (const InvalidRRTTL& ic) {
PyErr_Clear();
PyErr_SetString(po_InvalidRRTTL, ic.what());
return (-1);
......
......@@ -217,7 +217,7 @@ RRType_init(s_RRType* self, PyObject* args) {
PyErr_Clear();
return (0);
}
} catch (IncompleteRRType icc) {
} catch (const IncompleteRRType& icc) {
// Ok so one of our functions has thrown a C++ exception.
// We need to translate that to a Python Exception
// First clear any existing error that was set
......@@ -226,7 +226,7 @@ RRType_init(s_RRType* self, PyObject* args) {
PyErr_SetString(po_IncompleteRRType, icc.what());
// And return negative
return (-1);
} catch (InvalidRRType ic) {
} catch (const InvalidRRType& ic) {
PyErr_Clear();
PyErr_SetString(po_InvalidRRType, ic.what());
return (-1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment