Apache Solr open-source search software
SOLR-249 -- depreating new SolrException( int ... ) in favor of new SolrException( enum ...
Ryan McKinleye3dd7faecf0b
diff --git a/src/java/org/apache/solr/analysis/PatternTokenizerFactory.java b/src/java/org/apache/solr/analysis/PatternTokenizerFactory.javaindex 085fbe95e7f..3aaf738bfe3 100644--- a/src/java/org/apache/solr/analysis/PatternTokenizerFactory.java+++ b/src/java/org/apache/solr/analysis/PatternTokenizerFactory.java@@ -75,7 +75,7 @@ public class PatternTokenizerFactory implements TokenizerFactorythis.args = args;String regex = args.get( PATTERN );if( regex == null ) {- throw new SolrException( 500, "missing required argument: "+PATTERN );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "missing required argument: "+PATTERN );}int flags = 0; // TODO? -- read flags from config CASE_INSENSITIVE, etcpattern = Pattern.compile( regex, flags );@@ -87,7 +87,7 @@ public class PatternTokenizerFactory implements TokenizerFactorygroup = Integer.parseInt( g );}catch( Exception ex ) {- throw new SolrException( 500, "invalid group argument: "+g );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "invalid group argument: "+g );}}}@@ -124,7 +124,7 @@ public class PatternTokenizerFactory implements TokenizerFactory};}catch( IOException ex ) {- throw new SolrException( 500, ex );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, ex );}}diff --git a/src/java/org/apache/solr/analysis/PhoneticFilterFactory.java b/src/java/org/apache/solr/analysis/PhoneticFilterFactory.javaindex 678e823b6c1..0c4296d7b6e 100644--- a/src/java/org/apache/solr/analysis/PhoneticFilterFactory.java+++ b/src/java/org/apache/solr/analysis/PhoneticFilterFactory.java@@ -38,7 +38,7 @@ import org.apache.solr.core.SolrException;** "inject" (default=true) add tokens to the stream with the offset=0*- * @version $Id:$+ * @version $Id$* @see PhoneticFilter*/public class PhoneticFilterFactory extends BaseTokenFilterFactory@@ -69,19 +69,19 @@ public class PhoneticFilterFactory extends BaseTokenFilterFactoryString name = args.get( ENCODER );if( name == null ) {- throw new SolrException( 500, "Missing required parameter: "+ENCODER+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Missing required parameter: "+ENCODER+" ["+registry.keySet()+"]" );}Class<? extends Encoder> clazz = registry.get(name.toUpperCase());if( clazz == null ) {- throw new SolrException( 500, "Unknown encoder: "+name +" ["+registry.keySet()+"]" );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Unknown encoder: "+name +" ["+registry.keySet()+"]" );}try {encoder = clazz.newInstance();}catch (Exception e) {- throw new SolrException( 500, "Error initializing: "+name + "/"+clazz, e );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error initializing: "+name + "/"+clazz, e );}}diff --git a/src/java/org/apache/solr/analysis/TrimFilterFactory.java b/src/java/org/apache/solr/analysis/TrimFilterFactory.javaindex 66fb5b1f686..001353a0786 100644--- a/src/java/org/apache/solr/analysis/TrimFilterFactory.java+++ b/src/java/org/apache/solr/analysis/TrimFilterFactory.java@@ -40,7 +40,7 @@ public class TrimFilterFactory extends BaseTokenFilterFactory {updateOffsets = Boolean.valueOf( v );}catch( Exception ex ) {- throw new SolrException( 400, "Error reading updateOffsets value. Must be true or false.", ex );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Error reading updateOffsets value. Must be true or false.", ex );}}}diff --git a/src/java/org/apache/solr/core/Config.java b/src/java/org/apache/solr/core/Config.javaindex aa823bb079e..0173c9e7ca1 100644--- a/src/java/org/apache/solr/core/Config.java+++ b/src/java/org/apache/solr/core/Config.java@@ -96,7 +96,7 @@ public class Config {return o;} catch (XPathExpressionException e) {- throw new SolrException(500,"Error in xpath:" + path +" for " + name,e,false);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + path +" for " + name,e,false);}}@@ -122,12 +122,12 @@ public class Config {} catch (XPathExpressionException e) {SolrException.log(log,"Error in xpath",e);- throw new SolrException(500,"Error in xpath:" + xstr + " for " + name,e,false);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + xstr + " for " + name,e,false);} catch (SolrException e) {throw(e);} catch (Throwable e) {SolrException.log(log,"Error in xpath",e);- throw new SolrException(500,"Error in xpath:" + xstr+ " for " + name,e,false);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + xstr+ " for " + name,e,false);}}@@ -217,7 +217,7 @@ public class Config {}}- throw new SolrException(500, "Error loading class '" + cname + "'", e, false);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error loading class '" + cname + "'", e, false);}}@@ -226,7 +226,7 @@ public class Config {try {return clazz.newInstance();} catch (Exception e) {- throw new SolrException(500,"Error instantiating class " + clazz, e, false);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error instantiating class " + clazz, e, false);}}diff --git a/src/java/org/apache/solr/core/RequestHandlers.java b/src/java/org/apache/solr/core/RequestHandlers.javaindex 3dca2340396..16f075f98a1 100644--- a/src/java/org/apache/solr/core/RequestHandlers.java+++ b/src/java/org/apache/solr/core/RequestHandlers.java@@ -157,7 +157,7 @@ final class RequestHandlers {SolrRequestHandler old = register( name, handler );if( old != null ) {String msg = "multiple handlers registered on the same path! ignoring: "+old;- Throwable t = new SolrException( 500, msg );+ Throwable t = new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );SolrConfig.severeErrors.add( t );SolrException.logOnce(log,null,t);}@@ -252,7 +252,7 @@ final class RequestHandlers {_handler.init( _args );}catch( Exception ex ) {- throw new SolrException( 500, "lazy loading error", ex );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "lazy loading error", ex );}}return _handler;@@ -327,3 +327,4 @@ final class RequestHandlers {+diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.javaindex 52038408709..b29918196c7 100644--- a/src/java/org/apache/solr/core/SolrCore.java+++ b/src/java/org/apache/solr/core/SolrCore.java@@ -164,7 +164,7 @@ public final class SolrCore {} catch (SolrException e) {throw e;} catch (Exception e) {- throw new SolrException(500,"Error Instantiating Update Handler "+className, e);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error Instantiating Update Handler "+className, e);}}@@ -411,7 +411,7 @@ public final class SolrCore {String msg="Error opening new searcher. exceeded limit of maxWarmingSearchers="+maxWarmingSearchers + ", try again later.";log.warning(msg);// HTTP 503==service unavailable, or 409==Conflict- throw new SolrException(503,msg,true);+ throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE,msg,true);} else if (onDeckSearchers > 1) {log.info("PERFORMANCE WARNING: Overlapping onDeckSearchers=" + onDeckSearchers);}@@ -668,7 +668,7 @@ public final class SolrCore {SolrRequestHandler handler = getRequestHandler(req.getQueryType());if (handler==null) {log.warning("Unknown Request Handler '" + req.getQueryType() +"' :" + req);- throw new SolrException(400,"Unknown Request Handler '" + req.getQueryType() + "'", true);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Unknown Request Handler '" + req.getQueryType() + "'", true);}execute(handler, req, rsp);}@@ -690,7 +690,7 @@ public final class SolrCore {if( ep != null ) {EchoParamStyle echoParams = EchoParamStyle.get( ep );if( echoParams == null ) {- throw new SolrException(400,"Invalid value '" + ep + "' for " + SolrParams.HEADER_ECHO_PARAMS+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Invalid value '" + ep + "' for " + SolrParams.HEADER_ECHO_PARAMS+ " parameter, use '" + EchoParamStyle.EXPLICIT + "' or '" + EchoParamStyle.ALL + "'" );}if( echoParams == EchoParamStyle.EXPLICIT ) {@@ -777,3 +777,4 @@ public final class SolrCore {}+diff --git a/src/java/org/apache/solr/core/SolrException.java b/src/java/org/apache/solr/core/SolrException.javaindex ee9f3b883a8..6813b1840b1 100644--- a/src/java/org/apache/solr/core/SolrException.java+++ b/src/java/org/apache/solr/core/SolrException.java@@ -25,31 +25,80 @@ import java.io.PrintWriter;* @author yonik* @version $Id$*/--public class SolrException extends RuntimeException {++ /**+ * @since solr 1.2+ */+ public enum ErrorCode {+ BAD_REQUEST( 400 ),+ NOT_FOUND( 404 ),+ SERVER_ERROR( 500 ),+ SERVICE_UNAVAILABLE( 503 );++ final int code;++ private ErrorCode( int c )+ {+ code = c;+ }+ };+public boolean logged=false;+ public SolrException(ErrorCode code, String msg) {+ super(msg);+ this.code=code.code;+ }++ public SolrException(ErrorCode code, String msg, boolean alreadyLogged) {+ super(msg);+ this.code=code.code;+ this.logged=alreadyLogged;+ }++ public SolrException(ErrorCode code, String msg, Throwable th, boolean alreadyLogged) {+ super(msg,th);+ this.code=code.code;+ logged=alreadyLogged;+ }++ public SolrException(ErrorCode code, String msg, Throwable th) {+ this(code,msg,th,true);+ }++ public SolrException(ErrorCode code, Throwable th) {+ super(th);+ this.code=code.code;+ logged=true;+ }++ @Deprecatedpublic SolrException(int code, String msg) {super(msg);this.code=code;}++ @Deprecatedpublic SolrException(int code, String msg, boolean alreadyLogged) {super(msg);this.code=code;this.logged=alreadyLogged;}+ @Deprecatedpublic SolrException(int code, String msg, Throwable th, boolean alreadyLogged) {super(msg,th);this.code=code;logged=alreadyLogged;}+ @Deprecatedpublic SolrException(int code, String msg, Throwable th) {this(code,msg,th,true);}+ @Deprecatedpublic SolrException(int code, Throwable th) {super(th);this.code=code;@@ -87,6 +136,7 @@ public class SolrException extends RuntimeException {// public String toString() { return toStr(this); } // oops, inf loop+ @Overridepublic String toString() { return super.toString(); }public static String toStr(Throwable e) {diff --git a/src/java/org/apache/solr/handler/CSVRequestHandler.java b/src/java/org/apache/solr/handler/CSVRequestHandler.javaindex cef026725fa..3bf02780c44 100755--- a/src/java/org/apache/solr/handler/CSVRequestHandler.java+++ b/src/java/org/apache/solr/handler/CSVRequestHandler.java@@ -47,7 +47,7 @@ public class CSVRequestHandler extends RequestHandlerBase {Iterable<ContentStream> streams = req.getContentStreams();if (streams == null) {if(!RequestHandlerUtils.handleCommit(req, rsp, false)) {- throw new SolrException( 400, "missing content stream" );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "missing content stream" );}return;}@@ -189,7 +189,7 @@ abstract class CSVLoader {base.add(builder,line,column,val);}} catch (IOException e) {- throw new SolrException(400,"");+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"");}}}@@ -220,13 +220,13 @@ abstract class CSVLoader {strategy = new CSVStrategy(',', '"', CSVStrategy.COMMENTS_DISABLED, true, false, true);String sep = params.get(SEPARATOR);if (sep!=null) {- if (sep.length()!=1) throw new SolrException(400,"Invalid separator:'"+sep+"'");+ if (sep.length()!=1) throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Invalid separator:'"+sep+"'");strategy.setDelimiter(sep.charAt(0));}String encapsulator = params.get(ENCAPSULATOR);if (encapsulator!=null) {- if (encapsulator.length()!=1) throw new SolrException(400,"Invalid encapsulator:'"+sep+"'");+ if (encapsulator.length()!=1) throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Invalid encapsulator:'"+sep+"'");strategy.setEncapsulator(encapsulator.charAt(0));}@@ -242,7 +242,7 @@ abstract class CSVLoader {// assume the file has the headers if they aren't supplied in the argshasHeader=true;} else if (hasHeader) {- throw new SolrException(400,"CSVLoader: must specify fieldnames=<fields>* or header=true");+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"CSVLoader: must specify fieldnames=<fields>* or header=true");}} else {// if the fieldnames were supplied and the file has a header, we need to@@ -285,7 +285,7 @@ abstract class CSVLoader {for (String mapRule : fmap) {String[] mapArgs = colonSplit.split(mapRule,-1);if (mapArgs.length!=2)- throw new SolrException(400, "Map rules must be of the form 'from:to' ,got '"+mapRule+"'");+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Map rules must be of the form 'from:to' ,got '"+mapRule+"'");adders[i] = new CSVLoader.FieldMapperSingle(mapArgs[0], mapArgs[1], adders[i]);}}@@ -311,7 +311,7 @@ abstract class CSVLoader {sb.append(errHeader+", line="+lineno + ","+msg+"\n\tvalues={");for (String val: line) { sb.append("'"+val+"',"); }sb.append('}');- throw new SolrException(400,sb.toString());+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,sb.toString());}/** load the CSV input */@@ -333,7 +333,7 @@ abstract class CSVLoader {if (fieldnames==null) {fieldnames = parser.getLine();if (fieldnames==null) {- throw new SolrException(400,"Expected fieldnames in CSV input");+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Expected fieldnames in CSV input");}prepareFields();}@@ -388,3 +388,4 @@ class SingleThreadedCSVLoader extends CSVLoader {}}+diff --git a/src/java/org/apache/solr/handler/SpellCheckerRequestHandler.java b/src/java/org/apache/solr/handler/SpellCheckerRequestHandler.javaindex 81c439d532f..ec7ac6dfa2a 100644--- a/src/java/org/apache/solr/handler/SpellCheckerRequestHandler.java+++ b/src/java/org/apache/solr/handler/SpellCheckerRequestHandler.java@@ -113,7 +113,7 @@ public class SpellCheckerRequestHandler extends RequestHandlerBase {reopen();rsp.add("cmdExecuted","reopen");} else {- throw new SolrException(400, "Unrecognized Command: " + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Unrecognized Command: " + cmd);}}@@ -147,7 +147,7 @@ public class SpellCheckerRequestHandler extends RequestHandlerBase {private void rebuild(SolrQueryRequest req) throws IOException, SolrException {if (null == termSourceField) {throw new SolrException- (500, "can't rebuild spellchecker index without termSourceField configured");+ (SolrException.ErrorCode.SERVER_ERROR, "can't rebuild spellchecker index without termSourceField configured");}IndexReader indexReader = req.getSearcher().getReader();diff --git a/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.java b/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.javaindex 58945a89b68..f8161996d2b 100644--- a/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.java+++ b/src/java/org/apache/solr/handler/XmlUpdateRequestHandler.java@@ -72,7 +72,7 @@ public class XmlUpdateRequestHandler extends RequestHandlerBaseIterable<ContentStream> streams = req.getContentStreams();if( streams == null ) {if( !RequestHandlerUtils.handleCommit(req, rsp, false) ) {- throw new SolrException( 400, "missing content stream" );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "missing content stream" );}return;}@@ -262,7 +262,7 @@ public class XmlUpdateRequestHandler extends RequestHandlerBase(System.currentTimeMillis()-startTime));} else {log.warning("unexpected XML tag /delete/"+currTag);- throw new SolrException(400,"unexpected XML tag /delete/"+currTag);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unexpected XML tag /delete/"+currTag);}res.add( "delete", "" );@@ -303,7 +303,7 @@ public class XmlUpdateRequestHandler extends RequestHandlerBaseif (!"field".equals(tname)) {log.warning("unexpected XML tag doc/"+tname);- throw new SolrException(400,"unexpected XML tag doc/"+tname);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unexpected XML tag doc/"+tname);}//diff --git a/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java b/src/java/org/apache/solr/handler/admin/LukeRequestHandler.javaindex 1b6ddfc2e0e..1c0d5b1957c 100644--- a/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java+++ b/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java@@ -105,7 +105,7 @@ public class LukeRequestHandler extends RequestHandlerBaseTerm t = new Term( uniqueKey.getName(), v );docId = searcher.getFirstMatch( t );if( docId < 0 ) {- throw new SolrException( 404, "Can't find document: "+params.get( ID ) );+ throw new SolrException( SolrException.ErrorCode.NOT_FOUND, "Can't find document: "+params.get( ID ) );}}@@ -117,7 +117,7 @@ public class LukeRequestHandler extends RequestHandlerBase}catch( Exception ex ) {}if( doc == null ) {- throw new SolrException( 404, "Can't find document: "+docId );+ throw new SolrException( SolrException.ErrorCode.NOT_FOUND, "Can't find document: "+docId );}SimpleOrderedMap<Object> info = getDocumentFieldsInfo( doc, docId, reader, schema );@@ -533,3 +533,4 @@ public class LukeRequestHandler extends RequestHandlerBase+diff --git a/src/java/org/apache/solr/request/DisMaxRequestHandler.java b/src/java/org/apache/solr/request/DisMaxRequestHandler.javaindex 71a3190101a..4038a26d934 100644--- a/src/java/org/apache/solr/request/DisMaxRequestHandler.java+++ b/src/java/org/apache/solr/request/DisMaxRequestHandler.java@@ -227,7 +227,7 @@ public class DisMaxRequestHandler extends RequestHandlerBase {altUserQuery = p.parse(altQ);query.add( altUserQuery , Occur.MUST );} else {- throw new SolrException( 400, "missing query string" );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "missing query string" );}}else {diff --git a/src/java/org/apache/solr/request/RequiredSolrParams.java b/src/java/org/apache/solr/request/RequiredSolrParams.javaindex c07d10ed862..82d6059cf74 100755--- a/src/java/org/apache/solr/request/RequiredSolrParams.java+++ b/src/java/org/apache/solr/request/RequiredSolrParams.java@@ -47,7 +47,7 @@ public class RequiredSolrParams extends SolrParams {public String get(String param) {String val = params.get(param);if( val == null ) {- throw new SolrException( 400, "Missing required parameter: "+param );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Missing required parameter: "+param );}return val;}@@ -56,7 +56,7 @@ public class RequiredSolrParams extends SolrParams {public String[] getParams(String param) {String[] vals = params.getParams(param);if( vals == null || vals.length == 0 ) {- throw new SolrException( 400, "Missing required parameter: "+param );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Missing required parameter: "+param );}return vals;}diff --git a/src/java/org/apache/solr/request/SolrParams.java b/src/java/org/apache/solr/request/SolrParams.javaindex 2ec80bc7128..a8fe6de00d9 100644--- a/src/java/org/apache/solr/request/SolrParams.java+++ b/src/java/org/apache/solr/request/SolrParams.java@@ -252,7 +252,7 @@ public abstract class SolrParams {return val==null ? null : Integer.valueOf(val);}catch( Exception ex ) {- throw new SolrException( 400, ex.getMessage(), ex );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );}}@@ -263,7 +263,7 @@ public abstract class SolrParams {return val==null ? def : Integer.parseInt(val);}catch( Exception ex ) {- throw new SolrException( 400, ex.getMessage(), ex );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );}}@@ -275,7 +275,7 @@ public abstract class SolrParams {return val==null ? null : Integer.valueOf(val);}catch( Exception ex ) {- throw new SolrException( 400, ex.getMessage(), ex );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );}}@@ -287,7 +287,7 @@ public abstract class SolrParams {return val==null ? def : Integer.parseInt(val);}catch( Exception ex ) {- throw new SolrException( 400, ex.getMessage(), ex );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );}}@@ -299,7 +299,7 @@ public abstract class SolrParams {return val==null ? null : Float.valueOf(val);}catch( Exception ex ) {- throw new SolrException( 400, ex.getMessage(), ex );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );}}@@ -310,7 +310,7 @@ public abstract class SolrParams {return val==null ? def : Float.parseFloat(val);}catch( Exception ex ) {- throw new SolrException( 400, ex.getMessage(), ex );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );}}@@ -321,7 +321,7 @@ public abstract class SolrParams {return val==null ? null : Float.valueOf(val);}catch( Exception ex ) {- throw new SolrException( 400, ex.getMessage(), ex );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );}}@@ -333,7 +333,7 @@ public abstract class SolrParams {return val==null ? def : Float.parseFloat(val);}catch( Exception ex ) {- throw new SolrException( 400, ex.getMessage(), ex );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );}}@@ -349,7 +349,7 @@ public abstract class SolrParams {return false;}}- throw new SolrException( 400, "invalid boolean value: "+s );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "invalid boolean value: "+s );}/** Create a Map<String,String> from a NamedList given no keys are repeated */@@ -407,3 +407,4 @@ public abstract class SolrParams {+diff --git a/src/java/org/apache/solr/request/SolrQueryRequestBase.java b/src/java/org/apache/solr/request/SolrQueryRequestBase.javaindex 1bd1d671182..738bd482099 100644--- a/src/java/org/apache/solr/request/SolrQueryRequestBase.java+++ b/src/java/org/apache/solr/request/SolrQueryRequestBase.java@@ -98,7 +98,7 @@ public abstract class SolrQueryRequestBase implements SolrQueryRequest {public int getIntParam(String name) {String s = getParam(name);if (s==null) {- throw new SolrException(500,"Missing required parameter '"+name+"' from " + this);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Missing required parameter '"+name+"' from " + this);}return Integer.parseInt(s);}@@ -119,7 +119,7 @@ public abstract class SolrQueryRequestBase implements SolrQueryRequest {public String getStrParam(String name) {String s = getParam(name);if (s==null) {- throw new SolrException(500,"Missing required parameter '"+name+"' from " + this);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Missing required parameter '"+name+"' from " + this);}return s;}diff --git a/src/java/org/apache/solr/request/StandardRequestHandler.java b/src/java/org/apache/solr/request/StandardRequestHandler.javaindex 0f010eb3155..0c1ecf92be0 100644--- a/src/java/org/apache/solr/request/StandardRequestHandler.java+++ b/src/java/org/apache/solr/request/StandardRequestHandler.java@@ -93,7 +93,7 @@ public class StandardRequestHandler extends RequestHandlerBase {qstr = commands.get( 0 );}else if( commands.size() > 2 ) {- throw new SolrException( 400, "If you want to use multiple ';' in the query, use the 'sort' param." );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "If you want to use multiple ';' in the query, use the 'sort' param." );}}@@ -202,3 +202,4 @@ public class StandardRequestHandler extends RequestHandlerBase {+diff --git a/src/java/org/apache/solr/schema/DateField.java b/src/java/org/apache/solr/schema/DateField.javaindex faafc7abb81..f1f61d5fd0d 100644--- a/src/java/org/apache/solr/schema/DateField.java+++ b/src/java/org/apache/solr/schema/DateField.java@@ -102,10 +102,10 @@ public class DateField extends FieldType {try {return toInternal(p.parseMath(val.substring(3)));} catch (ParseException e) {- throw new SolrException(400,"Invalid Date Math String:'" +val+'\'',e);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Invalid Date Math String:'" +val+'\'',e);}}- throw new SolrException(400,"Invalid Date String:'" +val+'\'');+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Invalid Date String:'" +val+'\'');}public String toInternal(Date val) {diff --git a/src/java/org/apache/solr/schema/FieldType.java b/src/java/org/apache/solr/schema/FieldType.javaindex aa25e62cb71..ff1f336dc70 100644--- a/src/java/org/apache/solr/schema/FieldType.java+++ b/src/java/org/apache/solr/schema/FieldType.java@@ -170,7 +170,7 @@ public abstract class FieldType extends FieldProperties {try {val = toInternal(externalVal);} catch (NumberFormatException e) {- throw new SolrException(500, "Error while creating field '" + field + "' from value '" + externalVal + "'", e, false);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error while creating field '" + field + "' from value '" + externalVal + "'", e, false);}if (val==null) return null;if (!field.indexed() && !field.stored()) {diff --git a/src/java/org/apache/solr/schema/IndexSchema.java b/src/java/org/apache/solr/schema/IndexSchema.javaindex 539af49837d..61b28738f6f 100644--- a/src/java/org/apache/solr/schema/IndexSchema.java+++ b/src/java/org/apache/solr/schema/IndexSchema.java@@ -344,7 +344,7 @@ public final class IndexSchema {String msg = "[schema.xml] Duplicate fieldType definition for '"+ ft.typeName + "' ignoring: "+old.toString();- Throwable t = new SolrException( 500, msg );+ Throwable t = new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );SolrException.logOnce(log,null,t);SolrConfig.severeErrors.add( t );}@@ -370,7 +370,7 @@ public final class IndexSchema {FieldType ft = fieldTypes.get(type);if (ft==null) {- throw new SolrException(400,"Unknown fieldtype '" + type + "'",false);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Unknown fieldtype '" + type + "'",false);}Map<String,String> args = DOMUtil.toMapExcept(attrs, "name", "type");@@ -386,7 +386,7 @@ public final class IndexSchema {String msg = "[schema.xml] Duplicate field definition for '"+ f.getName() + "' ignoring: "+old.toString();- Throwable t = new SolrException( 500, msg );+ Throwable t = new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );SolrException.logOnce(log,null,t);SolrConfig.severeErrors.add( t );}@@ -408,7 +408,7 @@ public final class IndexSchema {String msg = "[schema.xml] Duplicate DynamicField definition for '"+ f.getName() + "' ignoring: "+f.toString();- Throwable t = new SolrException( 500, msg );+ Throwable t = new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );SolrException.logOnce(log,null,t);SolrConfig.severeErrors.add( t );dup = true;@@ -516,7 +516,7 @@ public final class IndexSchema {}}if( df == null ) {- throw new SolrException( 500, "copyField dynamic destination must match a dynamicField." );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "copyField dynamic destination must match a dynamicField." );}dCopies.add(new DynamicDestCopy(source, df ));}@@ -526,7 +526,7 @@ public final class IndexSchema {}else if( destIsPattern ) {String msg = "copyField only supports a dynamic destination if the source is also dynamic" ;- throw new SolrException( 500, msg );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );}else {// retrieve the field to force an exception if it doesn't exist@@ -553,7 +553,7 @@ public final class IndexSchema {} catch(Exception e) {// unexpected exception...SolrConfig.severeErrors.add( e );- throw new SolrException(500,"Schema Parsing Failed",e,false);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Schema Parsing Failed",e,false);}analyzer = new SolrIndexAnalyzer();@@ -588,7 +588,7 @@ public final class IndexSchema {NodeList nList = (NodeList)xpath.evaluate("./filter", node, XPathConstants.NODESET);if (tokNode==null){- throw new SolrException(500,"analyzer without class or tokenizer & filter list");+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"analyzer without class or tokenizer & filter list");}TokenizerFactory tfac = readTokenizerFactory(tokNode);@@ -598,7 +598,7 @@ public final class IndexSchema {NodeList nList = node.getChildNodes();TokenizerFactory tfac = readTokenizerFactory(nList.item(0));if (tfac==null) {- throw new SolrException(500,"TokenizerFactory must be specified first in analyzer");+ throw new SolrException( SolrException.StatusCode.SERVER_ERROR,"TokenizerFactory must be specified first in analyzer");}******/@@ -826,7 +826,7 @@ public final class IndexSchema {/*** REMOVED -YCSif (defaultFieldType != null) return new SchemaField(fieldName,defaultFieldType);***/- throw new SolrException(400,"undefined field "+fieldName);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"undefined field "+fieldName);}/**@@ -885,7 +885,7 @@ public final class IndexSchema {for (DynamicField df : dynamicFields) {if (df.matches(fieldName)) return df.prototype.getType();}- throw new SolrException(400,"undefined field "+fieldName);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"undefined field "+fieldName);}private FieldType dynFieldType(String fieldName) {@@ -947,3 +947,4 @@ public final class IndexSchema {+diff --git a/src/java/org/apache/solr/search/DocSet.java b/src/java/org/apache/solr/search/DocSet.javaindex ef6318e48e5..9eb19b153a3 100644--- a/src/java/org/apache/solr/search/DocSet.java+++ b/src/java/org/apache/solr/search/DocSet.java@@ -166,14 +166,14 @@ abstract class DocSetBase implements DocSet {* @throws SolrException Base implementation does not allow modifications*/public void add(int doc) {- throw new SolrException(500,"Unsupported Operation");+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Unsupported Operation");}/*** @throws SolrException Base implementation does not allow modifications*/public void addUnique(int doc) {- throw new SolrException(500,"Unsupported Operation");+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Unsupported Operation");}/**@@ -238,3 +238,4 @@ abstract class DocSetBase implements DocSet {+diff --git a/src/java/org/apache/solr/search/QueryParsing.java b/src/java/org/apache/solr/search/QueryParsing.javaindex dd0acb64770..26ea7ed3cc1 100644--- a/src/java/org/apache/solr/search/QueryParsing.java+++ b/src/java/org/apache/solr/search/QueryParsing.java@@ -73,7 +73,7 @@ public class QueryParsing {} catch (ParseException e) {SolrCore.log(e);- throw new SolrException(400,"Error parsing Lucene query",e);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Error parsing Lucene query",e);}}@@ -101,7 +101,7 @@ public class QueryParsing {} catch (ParseException e) {SolrCore.log(e);- throw new SolrException(400,"Query parsing error: " + e.getMessage(),e);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Query parsing error: " + e.getMessage(),e);}}@@ -177,12 +177,12 @@ public class QueryParsing {top = false;}else {- throw new SolrException( 400, "Unknown sort order: "+order);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Unknown sort order: "+order);}part = part.substring( 0, idx ).trim();}else {- throw new SolrException( 400, "Missing sort order." );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Missing sort order." );}if( "score".equals(part) ) {@@ -204,10 +204,10 @@ public class QueryParsing {f = schema.getField(part);}catch( SolrException e ){- throw new SolrException( 400, "can not sort on undefined field: "+part, e );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "can not sort on undefined field: "+part, e );}if (f == null || !f.indexed()){- throw new SolrException( 400, "can not sort on unindexed field: "+part );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "can not sort on unindexed field: "+part );}lst[i] = f.getType().getSortField(f,top);}diff --git a/src/java/org/apache/solr/tst/TestRequestHandler.java b/src/java/org/apache/solr/tst/TestRequestHandler.javaindex de52c8985a6..4a84c3ad03e 100644--- a/src/java/org/apache/solr/tst/TestRequestHandler.java+++ b/src/java/org/apache/solr/tst/TestRequestHandler.java@@ -78,7 +78,7 @@ public class TestRequestHandler implements SolrRequestHandler {// we need to un-escape them before we pass to QueryParsertry {String sreq = req.getQueryString();- if (sreq==null) throw new SolrException(400,"Missing queryString");+ if (sreq==null) throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Missing queryString");List<String> commands = StrUtils.splitSmart(sreq,';');String qs = commands.size() >= 1 ? commands.get(0) : "";@@ -301,3 +301,4 @@ public class TestRequestHandler implements SolrRequestHandler {}+diff --git a/src/java/org/apache/solr/update/DirectUpdateHandler.java b/src/java/org/apache/solr/update/DirectUpdateHandler.javaindex d935ac02fe5..e93cbf59428 100644--- a/src/java/org/apache/solr/update/DirectUpdateHandler.java+++ b/src/java/org/apache/solr/update/DirectUpdateHandler.java@@ -109,7 +109,7 @@ public class DirectUpdateHandler extends UpdateHandler {}protected boolean existsInIndex(String indexedId) throws IOException {- if (idField == null) throw new SolrException(400,"Operation requires schema to have a unique key field");+ if (idField == null) throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Operation requires schema to have a unique key field");closeWriter();openSearcher();@@ -127,7 +127,7 @@ public class DirectUpdateHandler extends UpdateHandler {protected int deleteInIndex(String indexedId) throws IOException {- if (idField == null) throw new SolrException(400,"Operation requires schema to have a unique key field");+ if (idField == null) throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Operation requires schema to have a unique key field");closeWriter(); openSearcher();IndexReader ir = searcher.getReader();@@ -173,9 +173,9 @@ public class DirectUpdateHandler extends UpdateHandler {// could return the number of docs deleted, but is that always possible to know???public void delete(DeleteUpdateCommand cmd) throws IOException {if (!cmd.fromPending && !cmd.fromCommitted)- throw new SolrException(400,"meaningless command: " + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"meaningless command: " + cmd);if (!cmd.fromPending || !cmd.fromCommitted)- throw new SolrException(400,"operation not supported" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"operation not supported" + cmd);String indexedId = idFieldType.toInternal(cmd.id);synchronized(this) {deleteInIndex(indexedId);@@ -187,9 +187,9 @@ public class DirectUpdateHandler extends UpdateHandler {// Depending on implementation, we may not be able to immediately determine num...public void deleteByQuery(DeleteUpdateCommand cmd) throws IOException {if (!cmd.fromPending && !cmd.fromCommitted)- throw new SolrException(400,"meaningless command: " + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"meaningless command: " + cmd);if (!cmd.fromPending || !cmd.fromCommitted)- throw new SolrException(400,"operation not supported" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"operation not supported" + cmd);Query q = QueryParsing.parseQuery(cmd.query, schema);@@ -221,7 +221,7 @@ public class DirectUpdateHandler extends UpdateHandler {} catch (IOException e) {try { closeSearcher(); } catch (Exception ee) { SolrException.log(SolrCore.log,ee); }SolrException.log(SolrCore.log,e);- throw new SolrException(500,"Error deleting doc# "+doc,e);+ throw new SolrException( SolrException.StatusCode.SERVER_ERROR,"Error deleting doc# "+doc,e);}}}@@ -324,21 +324,21 @@ public class DirectUpdateHandler extends UpdateHandler {return addConditionally(cmd);} else if (!cmd.allowDups && cmd.overwritePending && !cmd.overwriteCommitted) {// return overwriteBoth(cmd);- throw new SolrException(400,"unsupported param combo:" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unsupported param combo:" + cmd);} else if (!cmd.allowDups && cmd.overwritePending && cmd.overwriteCommitted) {return overwriteBoth(cmd);} else if (cmd.allowDups && !cmd.overwritePending && !cmd.overwriteCommitted) {return allowDups(cmd);} else if (cmd.allowDups && !cmd.overwritePending && cmd.overwriteCommitted) {// return overwriteBoth(cmd);- throw new SolrException(400,"unsupported param combo:" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unsupported param combo:" + cmd);} else if (cmd.allowDups && cmd.overwritePending && !cmd.overwriteCommitted) {// return overwriteBoth(cmd);- throw new SolrException(400,"unsupported param combo:" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unsupported param combo:" + cmd);} else if (cmd.allowDups && cmd.overwritePending && cmd.overwriteCommitted) {return overwriteBoth(cmd);}- throw new SolrException(400,"unsupported param combo:" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unsupported param combo:" + cmd);}public void close() throws IOException {diff --git a/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/src/java/org/apache/solr/update/DirectUpdateHandler2.javaindex e77c024bdff..673c8b53a97 100644--- a/src/java/org/apache/solr/update/DirectUpdateHandler2.java+++ b/src/java/org/apache/solr/update/DirectUpdateHandler2.java@@ -231,27 +231,27 @@ public class DirectUpdateHandler2 extends UpdateHandler {// protected with iwCommit (which iwAccess excludes from this block).synchronized (this) {if (!cmd.allowDups && !cmd.overwritePending && !cmd.overwriteCommitted) {- throw new SolrException(400,"unsupported param combo:" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unsupported param combo:" + cmd);// this would need a reader to implement (to be able to check committed// before adding.)// return addNoOverwriteNoDups(cmd);} else if (!cmd.allowDups && !cmd.overwritePending && cmd.overwriteCommitted) {rc = addConditionally(cmd);} else if (!cmd.allowDups && cmd.overwritePending && !cmd.overwriteCommitted) {- throw new SolrException(400,"unsupported param combo:" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unsupported param combo:" + cmd);} else if (!cmd.allowDups && cmd.overwritePending && cmd.overwriteCommitted) {rc = overwriteBoth(cmd);} else if (cmd.allowDups && !cmd.overwritePending && !cmd.overwriteCommitted) {rc = allowDups(cmd);} else if (cmd.allowDups && !cmd.overwritePending && cmd.overwriteCommitted) {- throw new SolrException(400,"unsupported param combo:" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unsupported param combo:" + cmd);} else if (cmd.allowDups && cmd.overwritePending && !cmd.overwriteCommitted) {- throw new SolrException(400,"unsupported param combo:" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unsupported param combo:" + cmd);} else if (cmd.allowDups && cmd.overwritePending && cmd.overwriteCommitted) {rc = overwriteBoth(cmd);}if (rc == -1)- throw new SolrException(400,"unsupported param combo:" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"unsupported param combo:" + cmd);if (rc == 1) {// adding document -- prep writer@@ -290,12 +290,12 @@ public class DirectUpdateHandler2 extends UpdateHandler {if (!cmd.fromPending && !cmd.fromCommitted) {numErrors.incrementAndGet();numErrorsCumulative.incrementAndGet();- throw new SolrException(400,"meaningless command: " + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"meaningless command: " + cmd);}if (!cmd.fromPending || !cmd.fromCommitted) {numErrors.incrementAndGet();numErrorsCumulative.incrementAndGet();- throw new SolrException(400,"operation not supported" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"operation not supported" + cmd);}iwCommit.lock();@@ -315,12 +315,12 @@ public class DirectUpdateHandler2 extends UpdateHandler {if (!cmd.fromPending && !cmd.fromCommitted) {numErrors.incrementAndGet();numErrorsCumulative.incrementAndGet();- throw new SolrException(400,"meaningless command: " + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"meaningless command: " + cmd);}if (!cmd.fromPending || !cmd.fromCommitted) {numErrors.incrementAndGet();numErrorsCumulative.incrementAndGet();- throw new SolrException(400,"operation not supported" + cmd);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"operation not supported" + cmd);}boolean madeIt=false;diff --git a/src/java/org/apache/solr/update/DocumentBuilder.java b/src/java/org/apache/solr/update/DocumentBuilder.javaindex 0778f8ebb40..bd4359e610e 100644--- a/src/java/org/apache/solr/update/DocumentBuilder.java+++ b/src/java/org/apache/solr/update/DocumentBuilder.java@@ -59,7 +59,7 @@ public class DocumentBuilder {if (!sfield.multiValued()) {String oldValue = map.put(sfield.getName(), val);if (oldValue != null) {- throw new SolrException(400,"ERROR: multiple values encountered for non multiValued field " + sfield.getName()+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"ERROR: multiple values encountered for non multiValued field " + sfield.getName()+ ": first='" + oldValue + "' second='" + val + "'");}}@@ -94,7 +94,7 @@ public class DocumentBuilder {// error if this field name doesn't match anythingif (sfield==null && (destArr==null || destArr.length==0)) {- throw new SolrException(400,"ERROR:unknown field '" + name + "'");+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"ERROR:unknown field '" + name + "'");}}@@ -134,7 +134,7 @@ public class DocumentBuilder {builder.append(field);builder.append(" ");}- throw new SolrException(400, builder.toString());+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, builder.toString());}Document ret = doc; doc=null;diff --git a/src/java/org/apache/solr/update/UpdateHandler.java b/src/java/org/apache/solr/update/UpdateHandler.javaindex ea3c9c6d029..e6892b73bea 100644--- a/src/java/org/apache/solr/update/UpdateHandler.java+++ b/src/java/org/apache/solr/update/UpdateHandler.java@@ -73,7 +73,7 @@ public abstract class UpdateHandler implements SolrInfoMBean {commitCallbacks.add(listener);log.info("added SolrEventListener for postCommit: " + listener);} catch (Exception e) {- throw new SolrException(500,"error parsing event listevers", e, false);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"error parsing event listevers", e, false);}}}@@ -88,7 +88,7 @@ public abstract class UpdateHandler implements SolrInfoMBean {optimizeCallbacks.add(listener);log.info("added SolarEventListener for postOptimize: " + listener);} catch (Exception e) {- throw new SolrException(500,"error parsing event listeners", e, false);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"error parsing event listeners", e, false);}}}@@ -129,15 +129,15 @@ public abstract class UpdateHandler implements SolrInfoMBean {protected final String getIndexedId(Document doc) {if (idField == null)- throw new SolrException(400,"Operation requires schema to have a unique key field");+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Operation requires schema to have a unique key field");// Right now, single valued fields that require value transformation from external to internal (indexed)// form have that transformation already performed and stored as the field value.Fieldable[] id = doc.getFieldables( idField.getName() );if (id == null || id.length < 1)- throw new SolrException(400,"Document is missing uniqueKey field " + idField.getName());+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Document is missing uniqueKey field " + idField.getName());if( id.length > 1 )- throw new SolrException(400,"Document specifies multiple unique ids! " + idField.getName());+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Document specifies multiple unique ids! " + idField.getName());return idFieldType.storedToIndexed( id[0] );}@@ -172,7 +172,7 @@ public abstract class UpdateHandler implements SolrInfoMBean {} catch (IOException e) {// don't try to close the searcher on failure for now...// try { closeSearcher(); } catch (Exception ee) { SolrException.log(log,ee); }- throw new SolrException(500,"Error deleting doc# "+doc,e,false);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error deleting doc# "+doc,e,false);}}}@@ -180,3 +180,4 @@ public abstract class UpdateHandler implements SolrInfoMBean {}+diff --git a/src/java/org/apache/solr/util/DOMUtil.java b/src/java/org/apache/solr/util/DOMUtil.javaindex 4d12a07307e..32662674481 100644--- a/src/java/org/apache/solr/util/DOMUtil.java+++ b/src/java/org/apache/solr/util/DOMUtil.java@@ -296,7 +296,7 @@ public class DOMUtil {}fragment = System.getProperty(propertyName,defaultValue);if (fragment == null) {- throw new SolrException(500, "No system property or default value specified for " + propertyName);+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "No system property or default value specified for " + propertyName);}}sb.append(fragment);diff --git a/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java b/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.javaindex 0a161d6e1c6..94a07325e06 100644--- a/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java+++ b/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java@@ -96,7 +96,7 @@ public class DirectSolrConnectionSystem.setProperty("java.util.logging.config.file", loggingConfig.getAbsolutePath() );}else {- throw new SolrException( 500, "can not find logging file: "+loggingConfig );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "can not find logging file: "+loggingConfig );}}@@ -105,7 +105,7 @@ public class DirectSolrConnectionif( Config.isInstanceDirInitialized() ) {String dir = Config.getInstanceDir();if( !dir.equals( instanceDir ) ) {- throw new SolrException( 500, "already initalized: "+dir );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "already initalized: "+dir );}}Config.setInstanceDir( instanceDir );@@ -150,12 +150,12 @@ public class DirectSolrConnectionString qt = params.get( SolrParams.QT );handler = core.getRequestHandler( qt );if( handler == null ) {- throw new SolrException( 400, "unknown handler: "+qt);+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "unknown handler: "+qt);}}}if( handler == null ) {- throw new SolrException( 400, "unknown handler: "+path );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "unknown handler: "+path );}// Make a stream for the 'body' contentdiff --git a/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java b/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.javaindex cb320bae88a..e0c5354ffc8 100644--- a/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java+++ b/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java@@ -143,11 +143,11 @@ public class SolrDispatchFilter implements FiltersolrReq = parsers.parse( path, req );String qt = solrReq.getParams().get( SolrParams.QT );if( qt != null && qt.startsWith( "/" ) ) {- throw new SolrException( 400, "Invalid query type. Do not use /select to access: "+qt);+ new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Invalid query type. Do not use /select to access: "+qt);}handler = core.getRequestHandler( qt );if( handler == null ) {- throw new SolrException( 400, "unknown handler: "+qt);+ new SolrException( SolrException.ErrorCode.BAD_REQUEST, "unknown handler: "+qt);}}}diff --git a/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java b/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.javaindex ba33a64867e..a4c186336c3 100644--- a/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java+++ b/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java@@ -117,7 +117,7 @@ public class SolrRequestParsersString[] strs = params.getParams( SolrParams.STREAM_URL );if( strs != null ) {if( !enableRemoteStreams ) {- throw new SolrException( 400, "Remote Streaming is disabled." );+ new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Remote Streaming is disabled." );}for( final String url : strs ) {ContentStreamBase stream = new ContentStreamBase.URLStream( new URL(url) );@@ -132,7 +132,7 @@ public class SolrRequestParsersstrs = params.getParams( SolrParams.STREAM_FILE );if( strs != null ) {if( !enableRemoteStreams ) {- throw new SolrException( 400, "Remote Streaming is disabled." );+ new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Remote Streaming is disabled." );}for( final String file : strs ) {ContentStreamBase stream = new ContentStreamBase.FileStream( new File(file) );@@ -185,7 +185,7 @@ public class SolrRequestParsers}}catch( UnsupportedEncodingException uex ) {- throw new SolrException( 500, uex );+ throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, uex );}}return new MultiMapSolrParams( map );@@ -303,7 +303,7 @@ class MultipartRequestParser implements SolrRequestParserfinal HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception{if( !ServletFileUpload.isMultipartContent(req) ) {- throw new SolrException( 400, "Not multipart content! "+req.getContentType() );+ new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Not multipart content! "+req.getContentType() );}MultiMapSolrParams params = SolrRequestParsers.parseQueryString( req.getQueryString() );@@ -378,7 +378,7 @@ class StandardRequestParser implements SolrRequestParser}return raw.parseParamsAndFillStreams(req, streams);}- throw new SolrException( 400, "Unsuported method: "+method );+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Unsuported method: "+method );}}@@ -389,3 +389,4 @@ class StandardRequestParser implements SolrRequestParser+diff --git a/src/webapp/src/org/apache/solr/servlet/SolrServlet.java b/src/webapp/src/org/apache/solr/servlet/SolrServlet.javaindex e66da9b7b8f..85cdd2ef07d 100644--- a/src/webapp/src/org/apache/solr/servlet/SolrServlet.java+++ b/src/webapp/src/org/apache/solr/servlet/SolrServlet.java@@ -61,7 +61,7 @@ public class SolrServlet extends HttpServlet {SolrRequestHandler handler = core.getRequestHandler(solrReq.getQueryType());if (handler==null) {log.warning("Unknown Request Handler '" + solrReq.getQueryType() +"' :" + solrReq);- throw new SolrException(400,"Unknown Request Handler '" + solrReq.getQueryType() + "'", true);+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,"Unknown Request Handler '" + solrReq.getQueryType() + "'", true);}core.execute(handler, solrReq, solrRsp );if (solrRsp.getException() == null) {