summaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc/org/postgresql/util/PSQLException.java
diff options
context:
space:
mode:
authorPeter Mount <peter@retep.org.uk>2001-01-25 09:16:36 +0000
committerPeter Mount <peter@retep.org.uk>2001-01-25 09:16:36 +0000
commitf118c36a7811b0a9e4c733863bc34c592c4a647f (patch)
tree317c03ce854b9539fa90bd5c990f8ba3000250e6 /src/interfaces/jdbc/org/postgresql/util/PSQLException.java
parent97f447b2cd81e029ca5008792c867512008f4b05 (diff)
downloadpostgresql-f118c36a7811b0a9e4c733863bc34c592c4a647f.tar.gz
Added an alternative constructor to PGSQLException so that debugging
some more osteric bugs is easier. If only 1 arg is supplied and it's of type Exception, then that Exception's stacktrace is now included. This was done as there's been a report of an unusual bug during connection. This will make this sort of bug hunting easier from now on.
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/util/PSQLException.java')
-rw-r--r--src/interfaces/jdbc/org/postgresql/util/PSQLException.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/util/PSQLException.java b/src/interfaces/jdbc/org/postgresql/util/PSQLException.java
index fbfca8e228..932bf6e357 100644
--- a/src/interfaces/jdbc/org/postgresql/util/PSQLException.java
+++ b/src/interfaces/jdbc/org/postgresql/util/PSQLException.java
@@ -1,5 +1,6 @@
package org.postgresql.util;
+import java.io.*;
import java.sql.*;
import java.text.*;
import java.util.*;
@@ -46,6 +47,34 @@ public class PSQLException extends SQLException
}
/**
+ * Helper version for 1 arg. This is used for debug purposes only with
+ * some unusual Exception's. It allows the originiating Exceptions stack
+ * trace to be returned.
+ */
+ public PSQLException(String error,Exception ex)
+ {
+ super();
+
+ Object[] argv = new Object[1];
+
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(baos);
+ pw.println("Exception: "+ex.toString()+"\nStack Trace:\n");
+ ex.printStackTrace(pw);
+ pw.println("End of Stack Trace");
+ pw.flush();
+ argv[0] = baos.toString();
+ pw.close();
+ baos.close();
+ } catch(Exception ioe) {
+ argv[0] = ex.toString()+"\nIO Error on stack trace generation! "+ioe.toString();
+ }
+
+ translate(error,argv);
+ }
+
+ /**
* Helper version for 2 args
*/
public PSQLException(String error,Object arg1,Object arg2)