Package org.apache.solr.common

## Class SolrException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.lang.RuntimeException
      - - org.apache.solr.common.SolrException

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `BaseHttpSolrClient.RemoteSolrException`, `CloudSolrClient.RouteException`, `NonExistentCoreException`

    public class SolrException
    extends RuntimeException

See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static class` `SolrException.ErrorCode` This list of valid HTTP Status error codes that Solr may return when there is a "Server Side" error.

### Field Summary

Fields
`protected NamedList<String>` `metadata`

### Constructor Summary

Constructors
`protected` `SolrException​(int code, String msg, Throwable th)` Constructor that can set arbitrary http status code.
`` `SolrException​(SolrException.ErrorCode code, String msg)`
`` `SolrException​(SolrException.ErrorCode code, String msg, Throwable th)`
`` `SolrException​(SolrException.ErrorCode code, Throwable th)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`int` `code()` The HTTP Status code associated with this Exception.
`NamedList<String>` `getMetadata()`
`String` `getMetadata​(String key)`
`static Throwable` `getRootCause​(Throwable t)`
`String` `getRootThrowable()`
`String` `getThrowable()`
`void` `log​(org.slf4j.Logger log)` Deprecated. Use the Logger directly
`static void` `log​(org.slf4j.Logger log, String msg)` Deprecated. Use the Logger directly
`static void` `log​(org.slf4j.Logger log, String msg, Throwable e)` Deprecated. Use the Logger directly
`static void` `log​(org.slf4j.Logger log, Throwable e)` Deprecated. Use the Logger directly
`void` `logDebugWithMdc​(org.slf4j.Logger logger, String msg)`
`void` `logInfoWithMdc​(org.slf4j.Logger logger, String msg)`
`void` `logWarnWithMdc​(org.slf4j.Logger logger, String msg)`
`void` `setMetadata​(String key, String value)`
`void` `setMetadata​(NamedList<String> metadata)`
`static SolrException` `wrapLuceneTragicExceptionIfNecessary​(Exception e)` Ensure that the provided tragic exception is wrapped in a 5xx SolrException

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### metadata

    protected NamedList<String> metadata

### Constructor Detail

#### SolrException

    public SolrException​(SolrException.ErrorCode code,
                         String msg)

#### SolrException

    public SolrException​(SolrException.ErrorCode code,
                         String msg,
                         Throwable th)

#### SolrException

    public SolrException​(SolrException.ErrorCode code,
                         Throwable th)

#### SolrException

    protected SolrException​(int code,
                            String msg,
                            Throwable th)

Constructor that can set arbitrary http status code. Not for use in Solr, but may be used by clients in subclasses to capture errors returned by the servlet container or other HTTP proxies.

### Method Detail

#### code

    public int code()

The HTTP Status code associated with this Exception. For SolrExceptions thrown by Solr "Server Side", this should be a valid `SolrException.ErrorCode`, however client side exceptions may contain an arbitrary error code based on the behavior of the Servlet Container hosting Solr, or any HTTP Proxies that may exist between the client and the server.

Returns:
  The HTTP Status code associated with this Exception

#### setMetadata

    public void setMetadata​(NamedList<String> metadata)

#### getMetadata

    public NamedList<String> getMetadata()

#### getMetadata

    public String getMetadata​(String key)

#### setMetadata

    public void setMetadata​(String key,
                            String value)

#### getThrowable

    public String getThrowable()

#### getRootThrowable

    public String getRootThrowable()

#### log

    @Deprecated
    public void log​(org.slf4j.Logger log)

Deprecated.
Use the Logger directly
This method was initially created to aid in testing situations that were known to cause ERRORs. It should no longer be used by any new code.

#### log

    @Deprecated
    public static void log​(org.slf4j.Logger log,
                           Throwable e)

Deprecated.
Use the Logger directly
This method was initially created to aid in testing situations that were known to cause ERRORs. It should no longer be used by any new code.

#### log

    @Deprecated
    public static void log​(org.slf4j.Logger log,
                           String msg,
                           Throwable e)

Deprecated.
Use the Logger directly
This method was initially created to aid in testing situations that were known to cause ERRORs. It should no longer be used by any new code.

#### log

    @Deprecated
    public static void log​(org.slf4j.Logger log,
                           String msg)

Deprecated.
Use the Logger directly
This method was initially created to aid in testing situations that were known to cause ERRORs. It should no longer be used by any new code.

#### getRootCause

    public static Throwable getRootCause​(Throwable t)

#### wrapLuceneTragicExceptionIfNecessary

    public static SolrException wrapLuceneTragicExceptionIfNecessary​(Exception e)

Ensure that the provided tragic exception is wrapped in a 5xx SolrException

Tragic exceptions (those that Lucene's IndexWriter uses to signify it has become inoperable) are expected to have a 5xx error code. This method takes an input tragic exception and adds the expected wrapper, if necessary.

Parameters:
  `e` - the exception to check the code on. If not a SolrException, then this method acts as a no-op.

#### logInfoWithMdc

    public void logInfoWithMdc​(org.slf4j.Logger logger,
                               String msg)

#### logDebugWithMdc

    public void logDebugWithMdc​(org.slf4j.Logger logger,
                                String msg)

#### logWarnWithMdc

    public void logWarnWithMdc​(org.slf4j.Logger logger,
                               String msg)