Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* Jackson JSON-processor.
   *
   * Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi
   */
  
  package divconq.json3;

Intermediate base class for all problems encountered when processing (parsing, generating) JSON content that are not pure I/O problems. Regular java.io.IOExceptions will be passed through as is. Sub-class of java.io.IOException for convenience.
 
 public class JsonProcessingException extends java.io.IOException
 {
     final static long serialVersionUID = 123; // Stupid eclipse...
 	
     protected JsonLocation _location;
 
     protected JsonProcessingException(String msgJsonLocation locThrowable rootCause) {
         /* Argh. IOException(Throwable,String) is only available starting
          * with JDK 1.6...
          */
         super(msg);
         if (rootCause != null) {
             initCause(rootCause);
         }
          = loc;
     }
 
     protected JsonProcessingException(String msg) {
         super(msg);
     }
 
     protected JsonProcessingException(String msgJsonLocation loc) {
         this(msglocnull);
     }
 
     protected JsonProcessingException(String msgThrowable rootCause) {
         this(msgnullrootCause);
     }
 
     protected JsonProcessingException(Throwable rootCause) {
         this(nullnullrootCause);
     }
 
     public JsonLocation getLocation() { return ; }
 
     /*
     /**********************************************************
     /* Extended API
     /**********************************************************
      */
 
     /*
      * Method that allows accessing the original "message" argument,
      * without additional decorations (like location information)
      * that overridden {@link #getMessage} adds.
      * 
      * @since 2.1
      */
     public String getOriginalMessage() { return super.getMessage(); }
 
     /*
     /**********************************************************
     /* Methods for sub-classes to use, override
     /**********************************************************
      */
     
     /*
      * Accessor that sub-classes can override to append additional
      * information right after the main message, but before
      * source location information.
      */
     protected String getMessageSuffix() { return null; }
 
     /*
     /**********************************************************
     /* Overrides of standard methods
     /**********************************************************
      */
     
     /*
      * Default method overridden so that we can add location information
      */
     @Override public String getMessage() {
         String msg = super.getMessage();
         if (msg == null) {
             msg = "N/A";
         }
         JsonLocation loc = getLocation();
         String suffix = getMessageSuffix();
         // mild optimization, if nothing extra is needed:
         if (loc != null || suffix != null) {
             StringBuilder sb = new StringBuilder(100);
             sb.append(msg);
             if (suffix != null) {
                 sb.append(suffix);
            }
            if (loc != null) {
                sb.append('\n');
                sb.append(" at ");
                sb.append(loc.toString());
            }
            msg = sb.toString();
        }
        return msg;
    }
    @Override public String toString() { return getClass().getName()+": "+getMessage(); }
New to GrepCode? Check out our FAQ X