package org.iotivity.service.ns.common;
-public class NSException extends Exception
-{
+/**
+ *
+ * This class provides implementation of exceptions thrown by API's.
+ *
+ */
+public class NSException extends Exception {
+
private NSErrorCode errorCode;
- public NSException(NSErrorCode errorCode, String errMessage)
- {
+ public NSException(NSErrorCode errorCode, String errMessage) {
super(errMessage + " " + errorCode.toString());
this.errorCode = errorCode;
}
- private NSException(String error, String errMessage)
- {
+ private NSException(String error, String errMessage) {
super(errMessage + " " + error);
this.errorCode = NSErrorCode.get(error);
}
- public NSErrorCode getErrorCode()
- {
+ public NSErrorCode getErrorCode() {
return errorCode;
}
- private static void addStackTrace(Throwable throwable,
- String file,
- String functionName,
- int line)
- {
+ private static void addStackTrace(Throwable throwable, String file,
+ String functionName, int line) {
StackTraceElement[] stack = throwable.getStackTrace();
StackTraceElement[] newStack = new StackTraceElement[stack.length + 1];
System.arraycopy(stack, 0, newStack, 1, stack.length);
- newStack[0] = new StackTraceElement("<native>", functionName, file, line);
+ newStack[0] = new StackTraceElement("<native>", functionName, file,
+ line);
throwable.setStackTrace(newStack);
}
- private void setNativeExceptionLocation(String file, String functionName, int line)
- {
+ private void setNativeExceptionLocation(String file, String functionName,
+ int line) {
NSException.addStackTrace(this, file, functionName, line);
}
}
\ No newline at end of file