/*
 * Copyright (C) 2004 Felipe Gustavo de Almeida
 * Copyright (C) 2010-2014 The MPDroid Project
 *
 * All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice,this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.a0z.mpd.exception;

/**
 * Represents an MPD Server error.
 * 
 * @author Felipe Gustavo de Almeida
 * @version $Id: MPDServerException.java 2716 2004-11-20 17:37:20Z galmeida $
 */
public class MPDServerException extends MPDException {

    private static final long serialVersionUID = 5986199004785561712L;

    /**
     * Constructor.
     */
    public MPDServerException() {
        super();
    }

    /**
     * Constructor.
     * 
     * @param message exception message.
     */
    public MPDServerException(String message) {
        super(message);
    }

    /**
     * Constructor.
     * 
     * @param message exception message.
     * @param cause cause of this exception.
     */
    public MPDServerException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * Constructor.
     * 
     * @param cause cause of this exception.
     */
    public MPDServerException(Throwable cause) {
        super(cause);
    }

}

@@ -1438,16 +1438,107 @@
 ption;%0A%0A
+import android.util.Log;%0A%0Aimport java.util.regex.Matcher;%0Aimport java.util.regex.Pattern;%0A%0A
 /**%0A * R
@@ -1819,16 +1819,254 @@
 1712L;%0A%0A
+    private static final String TAG = %22MPDServerException%22;%0A%0A    private String ackLine;%0A%0A    private final static Pattern ACK_CODE_PATTERN = Pattern.compile(%22%5B0-9%5D+%22);%0A%0A    public enum ErrorKind %7B%0A        PASSWORD,%0A        UNKOWN%0A    %7D%0A%0A
     /**%0A
@@ -2298,24 +2298,74 @@
   super(
+%22Server error:%22 + message);%0A        this.ackLine = 
 message
-)
 ;%0A    %7D%0A
@@ -2578,23 +2578,73 @@
 per(
-message, cause)
+%22Server error:%22 + message, cause);%0A        this.ackLine = message
 ;%0A  
@@ -2815,10 +2815,1051 @@
 %0A    %7D%0A%0A
+    /**%0A     * Get the MPD error that happened (after %22ACK%22);%0A     *%0A     * @return MPD's Error message%0A     */%0A    public String getAckLine() %7B%0A        return ackLine;%0A    %7D%0A%0A    /**%0A     * Parse the error kind from the ACK like and return it%0A     * Matches the return code using MPD's ack.h%0A     * Note : Only used errors are supported for the time being.%0A     * Other kinds will be recognized as %22UNKNOWN%22%0A     * @return The error kind%0A     */%0A    public ErrorKind getErrorKind() %7B%0A        int errorNumber = 5;%0A        ErrorKind errorKind = ErrorKind.UNKOWN;%0A        try %7B%0A            final Matcher matcher = ACK_CODE_PATTERN.matcher(getAckLine());%0A            errorNumber = Integer.parseInt(matcher.group(0));%0A            switch (errorNumber) %7B%0A                case 5:%0A                    errorKind = ErrorKind.PASSWORD;%0A            %7D%0A        %7D catch (Exception e) %7B%0A            Log.e(TAG, %22Error while extracting MPDServerException error code. ACK line : %22%0A                    + getAckLine());%0A        %7D%0A        return errorKind;%0A    %7D%0A
 %7D%0A

Add error kind support