Java Code Examples for java.lang.Exception#printStackTrace()

The following examples show how to use java.lang.Exception#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RetrieveDataTask.java    From gsn with GNU General Public License v3.0 6 votes vote down vote up
protected void onPostExecute(ArrayList<StreamElement> results) {
       if (results != null) {
           log(StaticData.globalContext, "Retrieved: " + results.size());
           try {
               for (StreamElement s : results) {
                   StaticData.getWrapperByName("tinygsn.model.wrappers.RemoteWrapper?" + su.getId()).postStreamElement(s);
               }
               su.setLastTime(System.currentTimeMillis());
               SqliteStorageManager storage = new SqliteStorageManager();
               storage.setSubscribeInfo(su.getId(), su.getUrl(), su.getVsname(), su.getMode(), su.getLastTime(), su.getIterationTime(), su.isActive(), su.getUsername(), su.getPassword());
           } catch (Exception e) {
               e.printStackTrace();
           }
       } else {
           log(StaticData.globalContext, "Error retrieving data from remote GSN.");
       }
}
 
Example 2
Source File: ExitParser.java    From exit_code_java with GNU General Public License v3.0 6 votes vote down vote up
public static void createNewSave(File pathToFile) throws IOException {
    pathToFile.getParentFile().mkdirs();
    InputStream stream = null;
    OutputStream resStreamOut = null;
    String jarFolder;
    try {
        stream = ExitParser.class.getResourceAsStream("/resources/save.ecsave");//note that each / is a directory down in the "jar tree" been the jar the root of the tree
        if(stream == null) {
            throw new Exception("Cannot get resource \"/resources/save.ecsave\" from Jar file.");
        }
        int readBytes;
        byte[] buffer = new byte[4096];
        resStreamOut = new FileOutputStream(pathToFile);
        while ((readBytes = stream.read(buffer)) > 0) {
            resStreamOut.write(buffer, 0, readBytes);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        stream.close();
        resStreamOut.close();
    }
}
 
Example 3
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
/**
 * Print text expecting markup formatting tags and a defined charset
 *
 * @param text
 * @param charset
 */
public void printTaggedText(String text, String charset) {
    try {
        mPrinter.printTaggedText(text, charset);
        mPrinter.flush();
        mCallbackContext.success();
    } catch (Exception e) {
        e.printStackTrace();
        Log.e(LOG_TAG, e.getMessage());
        mCallbackContext.error(this.getErrorByCode(5, e));
    }
}
 
Example 4
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
public void drawPageRectangle(int x, int y, int width, int height, int fillMode) {
    try {
        mPrinter.drawPageRectangle(x, y, width, height, fillMode);
        mCallbackContext.success();
    } catch (Exception e) {
        e.printStackTrace();
        mCallbackContext.error(this.getErrorByCode(12, e));
    }
}
 
Example 5
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
public void setPageRegion(int x, int y, int width, int height, int direction) {
    try {
        mPrinter.setPageRegion(x, y, width, height, direction);
        mCallbackContext.success();
    } catch (Exception e) {
        e.printStackTrace();
        mCallbackContext.error(this.getErrorByCode(15, e));
    }
}
 
Example 6
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
/**
 * Print a QRCode
 *
 * @param size - the size of symbol, value in {1, 4, 6, 8, 10, 12, 14}
 * @param eccLv - the error collection control level, where 1: L (7%), 2: M (15%), 3: Q (25%), 4: H (30%)
 * @param data - the QRCode data. The data must be between 1 and 448 symbols long.
 */
public void printQRCode(int size, int eccLv, String data) {
    try {
        mPrinter.printQRCode(size, eccLv, data);
        mPrinter.flush();
        mCallbackContext.success();
    } catch (Exception e) {
        e.printStackTrace();
        mCallbackContext.error(this.getErrorByCode(22, e));
    }
}
 
Example 7
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
/**
 * Print a Barcode
 *
 * @param type
 * @param data
 */
public void printBarcode(int type, String data) {
    try {
        mPrinter.printBarcode(type, data);
        mPrinter.flush();
        mCallbackContext.success();
    } catch (Exception e) {
        e.printStackTrace();
        mCallbackContext.error(this.getErrorByCode(8, e));
    }
}
 
Example 8
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
public void setBarcode(int align, boolean small, int scale, int hri, int height) {
    try {
        mPrinter.setBarcode(align, small, scale, hri, height);
        mCallbackContext.success();
    } catch (Exception e) {
        e.printStackTrace();
        mCallbackContext.error(this.getErrorByCode(10, e));
    }
}
 
Example 9
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
/**
 * Return Printer's head temperature
 */
public void getTemperature() {
    try {
        int temperature = mPrinter.getTemperature();
        mCallbackContext.success(temperature);
    } catch (Exception e) {
        e.printStackTrace();
        mCallbackContext.error(this.getErrorByCode(7, e));
    }
}
 
Example 10
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
/**
 * Return what is the Printer current status
 */
public void getStatus() {
    try {
        int status = mPrinter.getStatus();
        mCallbackContext.success(status);
    } catch (Exception e) {
        e.printStackTrace();
        mCallbackContext.error(this.getErrorByCode(6, e));
    }
}
 
Example 11
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
/**
 * Writes all bytes from the specified byte array to this printer
 *
 * @param byte[]
 */
public void write(byte[] b) {
    try {
        mPrinter.write(b);
        mPrinter.flush();
        mCallbackContext.success();
    } catch (Exception e) {
        e.printStackTrace();
        mCallbackContext.error(this.getErrorByCode(21, e));
    }
}
 
Example 12
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
public void printPage() {
    try {
        mPrinter.printPage();
        mPrinter.flush();
        mCallbackContext.success();
    } catch (Exception e) {
        e.printStackTrace();
        mCallbackContext.error(this.getErrorByCode(17, e));
    }
}
 
Example 13
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
/**
 * Cria um socket Bluetooth
 *
 * @param device
 * @param uuid
 * @param callbackContext
 * @return BluetoothSocket
 * @throws IOException
 */
private BluetoothSocket createBluetoothSocket(BluetoothDevice device, UUID uuid, final CallbackContext callbackContext) throws IOException {
    try {
        Method method = device.getClass().getMethod("createRfcommSocketToServiceRecord", new Class[] { UUID.class });
        return (BluetoothSocket) method.invoke(device, uuid);
    } catch (Exception e) {
        e.printStackTrace();
        sendStatusUpdate(false);
        callbackContext.error(this.getErrorByCode(19));
        showError(DatecsUtil.getStringFromStringResource(app, "failed_to_comm") + ": " + e.getMessage(), false);
    }
    return device.createRfcommSocketToServiceRecord(uuid);
}
 
Example 14
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
/**
 * Finaliza o socket Bluetooth e encerra todas as conexões
 */
private synchronized void closeBluetoothConnection() {
    BluetoothSocket socket = mBluetoothSocket;
    mBluetoothSocket = null;
    if (socket != null) {
        try {
            Thread.sleep(50);
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
Example 15
Source File: RetrieveDataTask.java    From gsn with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected List<StreamElement> doInBackground(String ... params) {
	apiUrl = params[0];
       List<StreamElement> se;
       try{
           connection = new Oauth2Connection(apiUrl, su.getUsername(), su.getPassword());
           connection.authenticate();
           StreamElement[] ses = StreamElement.fromJSON(connection.doJsonRequest("GET", "/api/sensors/"+su.getVsname()+"/" ,""));
           se = Arrays.asList(ses);
       }catch(Exception e){
           e.printStackTrace();
           se = null;
       }
	return se;
}
 
Example 16
Source File: GDelegateCenter.java    From grouter-android with Apache License 2.0 5 votes vote down vote up
Account2ServiceDelegate(StringBuilder stringBuilder) {
  try {
    targetClass = Class.forName("com.grouter.demo.Account2Service");
    Constructor<?> constructors = targetClass.getConstructor(StringBuilder.class);
    target = constructors.newInstance(stringBuilder);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
Example 17
Source File: GDelegateCenter.java    From grouter-android with Apache License 2.0 5 votes vote down vote up
Account2ServiceDelegate(Context context, int uid, int[] uids, Map userMap, List users, User user, String[] names) {
  try {
    targetClass = Class.forName("com.grouter.demo.Account2Service");
    Constructor<?> constructors = targetClass.getConstructor(Context.class,int.class,int[].class,Map.class,List.class,User.class,String[].class);
    target = constructors.newInstance(context,uid,uids,userMap,users,user,names);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
Example 18
Source File: DatecsSDKWrapper.java    From cordova-plugin-datecs-printer with MIT License 5 votes vote down vote up
public void selectPageMode() {
    try {
        mPrinter.selectPageMode();
        mCallbackContext.success();
    } catch (Exception e) {
        e.printStackTrace();
        mCallbackContext.error(this.getErrorByCode(14, e));
    }
}
 
Example 19
Source File: GDelegateCenter.java    From grouter-android with Apache License 2.0 5 votes vote down vote up
UserViewModelDelegate() {
  try {
    targetClass = Class.forName("com.grouter.demo.delegate.UserViewModel");
    target = targetClass.newInstance();
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
Example 20
Source File: GDelegateCenter.java    From grouter-android with Apache License 2.0 5 votes vote down vote up
MomentViewModelDelegate(Context context) {
  try {
    targetClass = Class.forName("com.grouter.demo.delegate.MomentViewModel");
    Constructor<?> constructors = targetClass.getConstructor(Context.class);
    target = constructors.newInstance(context);
  } catch (Exception e) {
    e.printStackTrace();
  }
}