|
|
Choosing A Webhost: |
Re: Error num in BadQuery patch: msg#00080db.mysql.c++
Jim Wallace wrote:
Oooh, you asked for it. :) + throw BadQuery(error(),errnum()); When submitting patches to any project, not just MySQL++, follow the coding conventions you see in the surrounding code. In this instance, there needs to be a space after commas. class MYSQLPP_EXPORT BadQuery : public Exception Hide this data member behind an accessor, make it private, and add an underscore to the end of its name to indicate that it's private. In other words, treat it just like Exception::what_. This is just another instance of following existing coding conventions. + /// \brief Create exception object, taking C string and error The briefer doxygen comment made sense with just one parameter, but with two, you should document both explicitly. I'd also document the reason why the error number is included, probably using your Transaction example; the docs should answer the question, "why would I use this instead of calling Connection::errnum()?" Ditto for the C++ string case. + explicit BadQuery(const char* w = "", int err = 0) : Variable initializations go on separate lines in the coding style used for MySQL++. Also, all of the changes to BadQuery also need to be made to ConnectionFailed and DBSelectionFailed. It's the same issue. And therefore, the same patch. --- query.cpp 2007-07-11 17:37:16.000000000 -0400 This is a bogus patch hunk. Examine a patch's diff carefully before submitting it to remove pointless little changes like this. You might be surprised how often you catch things like this. + /// \brief Get the last error number. This is orthogonal to the BadQuery changes, so it should be a separate patch. The first patch would call conn_->errnum() instead of Query::errnum(). The second would add this method and change all conn_->errnum() instances inside Query to just errnum(). This keeps the revision history clean, and ensures that you can separate effects due to each functional change. Another way to think about this is, if you were writing the svn checkin message, would it have to be a list, or a paragraph, or a run-on sentence? If so, the patch is probably trying to do too many things at once. This discipline helps you think more clearly about what each change is doing. if (!result_) { I think we need a new exception type here, not arm-twisting the current design to take a bogus error number. Historically, BadQuery was grossly overused; it was essentially a generic exception back in the 1.7 days. I think this is just a remnant of this problem. I suggest calling it UseQueryError. In keeping with earlier advice, I'd make this a separate patch, too. It should contain the new exception type defn and change the two BadQueries that don't take mysql_error() as the message to use it instead. if (!d || !r) { The MySQL error constant you're misusing here refers to SQL NULLs, not C NULLs. Also, it's another historical misuse of BadQuery. Use the ObjectNotInitialized exception here instead. (This is also a separate patch.) -- MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: http://lists.mysql.com/plusplus?unsub=gcdmc-plusplus@xxxxxxxxxxx
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Building the head of SVN with MSVC?, Warren Young |
|---|---|
| Next by Date: | Re: Error num in BadQuery patch, Warren Young |
| Previous by Thread: | Re: Error num in BadQuery patch, Warren Young |
| Next by Thread: | Threading problem in Windows, Hai Nguyen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |