@Override public ServiceRefAmp delegate() { throw new ServiceException(L.l("Pod root does not have a delegate")); }
private T getResultValue() { if (_exn != null) { throw ServiceException.createAndRethrow(_exn); } else { return _value; } }
public ServiceException rethrow(String msg) { ServiceException exn = new ServiceException(msg, this); exn.fillInStackTrace(); return exn; } }
/** * Rethrows an exception to record the full stack trace, both caller * and callee. */ public ServiceException rethrow() { return rethrow(getMessage()); }
public static ServiceException createAndRethrow(Throwable exn) { ServiceException exn1; if (exn instanceof ServiceException) { exn1 = ((ServiceException) exn).rethrow(); } else { exn1 = new ServiceExceptionExecution(exn); } exn1.fillInStackTrace(); return exn1; }
@Override public final void deliver(final MessageAmp msg, Outbox outbox) throws Exception { try { msg.invoke(_inbox, _actorDeliver); } catch (ServiceException e) { log.fine(e.toString()); } catch (Throwable e) { log.log(Level.WARNING, this + " " + e.toString(), e); } }
address(), serverId)); exn.fillInStackTrace();
public static ServiceException createAndRethrow(Throwable exn) { if (exn instanceof ServiceException) { return ((ServiceException) exn).rethrow(); } else { return new AmpException(exn); } } }
protected void printException(RequestWeb req, Throwable exn) throws IOException { // nam: 2014-05-08 String jsonCallback = req.path("jsoncallback"); if (jsonCallback != null) { req.write(jsonCallback); req.write("("); } if (exn instanceof ServiceException) { ServiceException sExn = (ServiceException) exn; req.write("{\"status\":\"" + sExn.getCode() + "\""); req.write(",\"message\":\"" + exn.toString() + "\"}"); } else { req.write("{\"status\":\"exception\",\"message\":\"" + exn.toString() + "\"}"); } // exn.printStackTrace(); if (log.isLoggable(Level.FINER)) { log.log(Level.FINER, exn.toString(), exn); } if (jsonCallback != null) { req.write(")"); } }
public static ServiceException createAndRethrow(String msg, Throwable exn) { ServiceException exn1; if (exn instanceof ServiceException) { exn1 = ((ServiceException) exn).rethrow(msg); } else { exn1 = new ServiceExceptionExecution(msg, exn); } exn1.fillInStackTrace(); return exn1; }
@Override public boolean isClosed() { try { return getActiveService().isClosed(); } catch (ServiceException e) { log.log(Level.FINEST, e.toString(), e); return false; } }
public static RuntimeException wrap(Throwable exn) { if (exn instanceof ServiceException) { return ((ServiceException) exn).rethrow(); } else if (exn instanceof RuntimeException) { try { Constructor<?> ctor = exn.getClass().getConstructor(String.class,Throwable.class); return (RuntimeException) ctor.newInstance(exn.getMessage(), exn); } catch (Exception e) { return new ServiceExceptionExecution(exn); } } else { return new ServiceExceptionExecution(exn); } } }
private RuntimeException error(String msg, Object ...args) { return new ServiceException(L.l(msg, args)); }
@Override public void query(HeadersAmp headers, ResultChain<?> result, StubAmp actor, Object []args) { Object bean = actor.bean(); if (log.isLoggable(Level.FINER)) { log.finest("amp-send to stream " + name() + "[" + bean + "] " + toList(args)); } ServiceException exn = new ServiceException(L.l(bean + "." + name() + " is a stream method")); exn.fillInStackTrace(); result.fail(exn); }
public void load(Cursor cursor, T entity) { try { Objects.requireNonNull(cursor); Objects.requireNonNull(entity); load(cursor, entity, false); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw ServiceException.createAndRethrow(e); } }
msg.invoke(_inbox, _actor); } catch (ServiceException e) { log.fine(e.toString()); } catch (Throwable e) { log.log(Level.WARNING, this + " " + e.toString(), e); msg.invoke(_inbox, _actor); } catch (ServiceException e) { log.fine(e.toString()); } catch (Throwable e) { log.log(Level.WARNING, this + " " + e.toString(), e);
@Override public void subscribe(ResultStream<T> subscriber) { Objects.requireNonNull(subscriber); if (subscriber.isCancelled()) { throw new ServiceException(L.l("Subscriber is closed")); } _subscriberList.add(subscriber); cleanSubscribers(); }
@Override public void query(HeadersAmp headers, ResultChain<?> result, StubAmp actor, Object []args) { Object bean = actor.bean(); if (log.isLoggable(Level.FINER)) { log.finest("amp-send to stream " + name() + "[" + bean + "] " + toList(args)); } ServiceException exn = new ServiceException(L.l(bean + "." + name() + " is a stream method")); exn.fillInStackTrace(); result.fail(exn); }
public T peek(T defaultValue) { // flush any pending messages // ServiceRef.flushOutbox(); if (! isDone()) { return defaultValue; } else if (_exn != null) { throw ServiceException.createAndRethrow(_exn); } else { return _value; } }
@Override public void consume(ResultStream<T> subscriber) { Objects.requireNonNull(subscriber); if (subscriber.isCancelled()) { throw new ServiceException(L.l("Subscriber is closed")); } _subscriberList.add(subscriber); cleanSubscribers(); }