Package com.eshore.ismp.pay.common.exception, @SuppressWarnings ("Serial") public class Payexception extends exception {private int exceptionid;//error code private String info;//error message public payexception (int exceptionid, String info) {super (); Exceptionid = Exceptionid;this.info = info;} Public payexception (Int. exceptionid) {Exceptionid = Exceptionid;} public payexception (String info) {super (info); This.info = info;} Public String toString () { return (new StringBuilder ()). Append ("Payexception,code="). Append (Exceptionid). ToString (); } Public String GetInfo () {return info,} public int Getexceptionid () {return exceptionid;} public static Byte INTERNAL =-2; Internal error public static byte mdb_internal = -6;//Database Error}
Need to inherit exception class
Then a class is going to use this exception class first throws Exception
And then
} catch (HttpException e) {throw new Payexception (Payexception.internal,e.getmessage ());} catch (IOException e) { Postmethod.releaseconnection ();//Consider long connections? Simplehttpconnectionmanager connm = (Simplehttpconnectionmanager) Httpclient.gethttpconnectionmanager (); Connm.closeidleconnections (0); throw new Payexception (Payexception.internal,e.getmessage ());
Similar to the above, so that we can determine where the problem is due to the error code thrown.
Java Custom Exceptions