Solr - Exception Handling -


i using solr(on tomcat server) webservices. when end user pass solr query url, request goes through webservice , render result in browser. in case of exception, getting http error 500 followed trace log in browser. not want end user see trace log wanted display custom error message in browser.

any idea on how can achieve ?

code snippet using

private integer determinestart(final string start) throws dqsexception {         integer intvalue = null;         try{             intvalue = integer.valueof(start) ;             return intvalue;         }         catch(numberformatexception e){             throw new dqsexception(                     "start should numeric value >= 0");         }     } 

customized exception

public class dqsexception extends exception {      /**      *       */     private static final long serialversionuid = 7669894738044609438l;      public dqsexception(string message, throwable e) {         super(message,e);     }      public dqsexception(string message) {         super(message);     }  } 

exception in browser

http error 500 problem accessing /dqs/query/hrportal/select. reason: server error caused by: com.fmr.ctg.hr.hrdh.dqs.execptions.dqsexception: start should numeric value >= 0 @ com.fmr.ctg.hr.hrdh.dqs.rest.queryservice.determinestart(queryservice.java:245) @ com.fmr.ctg.hr.hrdh.dqs.rest.queryservice.selectall(queryservice.java:74) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)

    ...     ... 

expected error message in browser without stack trace logs:

start should numeric value >= 0

any pointers appreciated.

many thanks!

you can put try-catch block round code , return custom error message.

check out webservice written in c# idea:

http://amac4.blogspot.com/2013/07/web-service-to-query-solr-rest.html


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -