@Test public void testPush() { String contexts[] = new String[]{"1", "2"}; String errorCode = "code"; StringBuilder buff = new StringBuilder(); for (String context : contexts) { if (buff.length() > 0) { buff.append(Error.DELIMITER); } Error.push(context); buff.append(context); } Error e = Error.get(errorCode); Assert.assertEquals(buff.toString(), e.getContext()); Assert.assertEquals(errorCode, e.getErrorCode()); }
public static void push(String context) { if (null == context) { context = "null"; } LOGGER.debug("push: {}", context); THREAD_CONTEXT.get().addLast(context); }
Error extends RuntimeException { public static void push(String context) { if (null == context) { context = "null"; } LOGGER.debug("push: {}", context); THREAD_CONTEXT.get().addLast(context); } }
Error extends RuntimeException { public static void push(String context) { if (null == context) { context = "null"; } LOGGER.debug("push: {}", context); THREAD_CONTEXT.get().addLast(context); } private  Error(String errorCode, String msg); private  Error(ArrayDeque<String> context, String errorCode, String msg); }
Error extends RuntimeException { public static void push(String context) { if (null == context) { context = "null"; } LOGGER.debug("push: {}", context); THREAD_CONTEXT.get().addLast(context); } private  Error(String errorCode, String msg); private  Error(ArrayDeque<String> context, String errorCode, String msg); static void push(String context); static void pop(); static Error get(String ctx, String errorCode, String msg); static Error get(String ctx, String errorCode, Throwable e); static Error get(String errorCode, String msg); static Error get(String errorCode, Throwable e); static Error get(Throwable e); static Error get(String errorCode); static void reset(); void pushContext(String context); void popContext(); String getErrorCode(); String getMsg(); String getContext(); JsonNode toJson(); @Override String toString(); @Override String getMessage(); static Error fromJson(JsonNode node); }
Error extends RuntimeException { public static void push(String context) { if (null == context) { context = "null"; } LOGGER.debug("push: {}", context); THREAD_CONTEXT.get().addLast(context); } private  Error(String errorCode, String msg); private  Error(ArrayDeque<String> context, String errorCode, String msg); static void push(String context); static void pop(); static Error get(String ctx, String errorCode, String msg); static Error get(String ctx, String errorCode, Throwable e); static Error get(String errorCode, String msg); static Error get(String errorCode, Throwable e); static Error get(Throwable e); static Error get(String errorCode); static void reset(); void pushContext(String context); void popContext(); String getErrorCode(); String getMsg(); String getContext(); JsonNode toJson(); @Override String toString(); @Override String getMessage(); static Error fromJson(JsonNode node); static final char DELIMITER; }