Changeset 532 for branches

Show
Ignore:
Timestamp:
09/19/07 17:41:53 (14 months ago)
Author:
david
Message:
  • throw exception on bad connection
Location:
branches/strict-xml-branch/plugins/input/postgis
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/strict-xml-branch/plugins/input/postgis/connection.hpp

    r485 r532  
    2626#define CONNECTION_HPP 
    2727 
     28#include <mapnik/datasource.hpp> 
     29 
    2830extern "C"  
    2931{ 
     
    4244      { 
    4345         conn_=PQconnectdb(connection_str.c_str()); 
    44          if (PQstatus(conn_) == CONNECTION_BAD) 
     46         if (PQstatus(conn_) != CONNECTION_OK) 
    4547         { 
    46             std::clog << "connection  ["<< connection_str<< "] failed\n" 
    47                       << PQerrorMessage(conn_)<< std::endl; 
     48             std::string s("PSQL error"); 
     49             if (conn_ ) 
     50             { 
     51                 std::string msg = PQerrorMessage( conn_ ); 
     52                 if ( ! msg.empty() ) 
     53                 { 
     54                     s += ":\n" + msg.substr( 0, msg.size() - 1 ); 
     55                 } 
     56             }  
     57             throw mapnik::datasource_exception( s ); 
    4858         } 
    4959      } 
  • branches/strict-xml-branch/plugins/input/postgis/connection_manager.hpp

    r485 r532  
    5858      T* operator()() const 
    5959      { 
    60          return new T(connection_string()); 
     60          return new T(connection_string()); 
    6161      } 
    6262