package info.izumin.android.bletia;

import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;

/**
 * Created by izumin on 9/14/15.
 */
public class BletiaException extends Exception {

    private final BletiaErrorType mType;
    private BluetoothGattCharacteristic mCharacteristic;
    private BluetoothGattDescriptor mDescriptor;

    public BletiaException(BletiaErrorType type) {
        this(type.getName(), type);
    }

    public BletiaException(BletiaErrorType type, BluetoothGattCharacteristic characteristic) {
        this(type, characteristic, null);
    }

    public BletiaException(BletiaErrorType type, BluetoothGattDescriptor descriptor) {
        this(type, null, descriptor);
    }

    public BletiaException(BletiaErrorType type, BluetoothGattCharacteristic characteristic, BluetoothGattDescriptor descriptor) {
        this(type);
        mCharacteristic = characteristic;
        mDescriptor = descriptor;
    }

    public BletiaException(String detailMessage, BletiaErrorType type) {
        super(detailMessage);
        this.mType = type;
    }

    public BletiaErrorType getType() {
        return mType;
    }

    public BluetoothGattCharacteristic getCharacteristic() {
        return mCharacteristic;
    }

    public BluetoothGattDescriptor getDescriptor() {
        return mDescriptor;
    }
}

@@ -29,32 +29,44 @@
 bletia;%0A%0Aimport 
+info.izumin.
 android.bluetoot
@@ -63,93 +63,26 @@
 d.bl
-u
 et
-ooth.BluetoothGattCharacteristic;%0Aimport android.bluetooth.BluetoothGattDescriptor
+ia.action.Action
 ;%0A%0A/
@@ -171,16 +171,47 @@
 tion %7B%0A%0A
+    private final String mTag;%0A
     priv
@@ -259,100 +259,29 @@
 ate 
-BluetoothGattCharacteristic mCharacteristic;%0A    private BluetoothGattDescriptor mDescriptor
+Action mAction = null
 ;%0A%0A 
@@ -298,32 +298,47 @@
 BletiaException(
+Action action, 
 BletiaErrorType 
@@ -354,24 +354,32 @@
        this(
+action, 
 type.getName
@@ -427,116 +427,163 @@
 ion(
-BletiaErrorType type, BluetoothGattCharacteristic characteristic) %7B%0A        this(type, characteristic, null)
+Action action, String detailMessage, BletiaErrorType type) %7B%0A        this(action.getClass().getSimpleName(), detailMessage, type);%0A        mAction = action
 ;%0A  
@@ -609,35 +609,32 @@
 tiaException(Ble
-tia
 ErrorType type, 
@@ -635,83 +635,99 @@
 type
-, BluetoothGattDescriptor descriptor) %7B%0A        this(type, null, descriptor
+) %7B%0A        super();%0A        mType = type;%0A        mTag = getStackTrace()%5B0%5D.getMethodName(
 );%0A 
@@ -759,16 +759,28 @@
 ception(
+String tag, 
 BletiaEr
@@ -795,323 +795,381 @@
 type
-, BluetoothGattCharacteristic characteristic
+) %7B%0A        this(tag, type.getName(), type);%0A    %7D%0A%0A    public BletiaException(String tag, String detailMessage
 , Bl
-u
 et
-oothGattDescriptor descriptor) %7B%0A        this(type);%0A        mCharacteristic = characteristic;%0A        mDescriptor = descriptor;%0A    %7D%0A%0A    public BletiaException(
+iaErrorType type) %7B%0A        super(detailMessage);%0A        mType = type;%0A        mTag = tag;%0A    %7D%0A%0A    @Override%0A    public 
 String 
-d
+g
 et
-ail
 Message
-, BletiaErrorType type) %7B%0A        super(detail
+() %7B%0A        return %22%5B%22 + mTag + %22%5D %22 + super.get
 Message
+(
 );%0A    
+%7D%0A%0A
     
-this.mType = type
+public String getTag() %7B%0A        return mTag
 ;%0A  
@@ -1256,53 +1256,24 @@
 lic 
-BluetoothGattCharacteristic getCharacteristic
+Action getAction
 () %7B
@@ -1293,22 +1293,14 @@
 rn m
-Characteristic
+Action
 ;%0A  
@@ -1319,45 +1319,31 @@
 lic 
-BluetoothGattDescriptor getDescriptor
+boolean doCauseByAction
 () %7B
@@ -1363,18 +1363,22 @@
 rn m
-Descriptor
+Action != null
 ;%0A  

Improve BletiaException constructor