All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.docshare.mvc.except.MVCException Maven / Gradle / Ivy

Go to download

An efficient, fast, convenient, easy to learn, easy to use MVC framework and ORM framework. It is seamless compatible with JSTL and supports FreeMarker. It can run independently, and it can also be applied to traditional Java Web projects. It is an efficient, fast, convenient, easy to learn and easy to use MVC framework and ORM framework. It is seamless compatible with JSTL and supports FreeMarker. It can be run on its own, or it can be applied to traditional Java Web projects

There is a newer version: 2023.06.19
Show newest version
package org.docshare.mvc.except;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;

import org.docshare.util.TextTool;


public class MVCException extends RuntimeException{
	private String msg = "";
	/**
	 * 
	 */
	private static final long serialVersionUID = -4515480661510346678L;
	private Throwable throwable = null;

	public MVCException(String msg) {
		super(msg);
		this.msg = msg;
	}
	public MVCException(Throwable throwable){
		this.throwable  = throwable;
	}
	public MVCException(String msg,Throwable throwable){
		super(msg);
		this.msg = msg;
		this.throwable = throwable;
	}
	public MVCException(String...args) {
		super();
		this.msg = TextTool.concat((Object[])args).toString();
	}
	
	@Override
	public void printStackTrace(PrintStream s) {
		s.println("Message: "+msg);
		if(throwable!=null){
			s.print(toString(throwable));
			s.flush();
			return;
			//s.println("~~~~~~~~~~~~  The Message is above ~~~~~~~~~~~");
		}
		super.printStackTrace(s);
	}
	@Override
	public void printStackTrace(PrintWriter s) {
		s.println("Message: "+msg);
		if(throwable!=null){
			//throwable.printStackTrace(s);
			s.print(toString(throwable));
			s.flush();
			return;
			//s.println("~~~~~~~~~~~~  The Message is above ~~~~~~~~~~~"); 
		}
		super.printStackTrace(s);
	}
	private String toString(Throwable t){
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		PrintWriter pw  =new PrintWriter(bos);
		t.printStackTrace(pw);
		pw.flush();
		pw.close();
		
		String str = new String(bos.toByteArray());
		StringBuilder sb =new StringBuilder();
		for(String s:str.split("\n")){
			if(s.contains("org.eclipse.jetty")){
				break;
			}
			sb.append(s+"\n");
		}
		return sb.toString();
		
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy