@Override public Object fromXml(final JAXBContext jaxbContext, final String xml, final Map<String, Object> unmarshallerProperties) { try { return internalFromXml(jaxbContext, xml, unmarshallerProperties); } catch (final JAXBException ex) { throw new NonRecoverableException("Error unmarshalling XML", ex); } }
@Override public String getMessage() { return getTranslatableMessage() != null ? getTranslatableMessage().getPattern() : super.getMessage(); }
@NotPersisted public List<SimpleEntity> getNotPersisted() { throw new org.apache.isis.applib.NonRecoverableException("unexpected call"); } // }}
@NotPersisted public SimpleEntity getNotPersisted() { throw new org.apache.isis.applib.NonRecoverableException("unexpected call"); } // }}
private static <T> JAXBContext jaxbContextFor(final Class<T> clazz) { try { return JaxbUtil.jaxbContextFor(clazz); } catch (RuntimeException e) { throw new NonRecoverableException("Error obtaining JAXBContext for class '" + clazz + "'", e.getCause()); } }
@NotPersisted public int getNotPersisted() { throw new org.apache.isis.applib.NonRecoverableException("unexpected call"); } // }}
private EventBusImplementation instantiateEventBus() { if("guava".equals(implementation)) { return new EventBusImplementationForGuava(); } if("axon".equals(implementation)) { return new EventBusImplementationForAxonSimple(); } final Class<?> aClass = ClassUtil.forName(implementation); if(EventBusImplementation.class.isAssignableFrom(aClass)) { try { return (EventBusImplementation) aClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new NonRecoverableException(e); } } throw new NonRecoverableException( "Could not instantiate event bus implementation '" + implementation + "'"); } //endregion
throw new NonRecoverableException( "Error marshalling domain object to XML, due to illegal annotations on domain object class '" + domainClass.getName() + "'; " + errors.size() + " error" throw new NonRecoverableException("Error marshalling domain object to XML; domain object class is '" + domainClass.getName() + "'", ex);
@Override public Object fromXml(final JAXBContext jaxbContext, final String xml, final Map<String, Object> unmarshallerProperties) { try { Object pojo = internalFromXml(jaxbContext, xml, unmarshallerProperties); if(pojo instanceof DomainObjectList) { // go around the loop again, so can properly deserialize the contents DomainObjectList list = (DomainObjectList) pojo; JAXBContext jaxbContextForList = jaxbContextFor(list); return internalFromXml(jaxbContextForList, xml, unmarshallerProperties); } return pojo; } catch (final JAXBException ex) { throw new NonRecoverableException("Error unmarshalling XML", ex); } }
private void onExecutedThrowExceptionIfSet() { if(getSubscriberBehaviour() == DemoBehaviour.ANY_EXECUTE_VETO_WITH_RECOVERABLE_EXCEPTION) { throw new RecoverableException( TranslatableString.tr("Rejecting event (recoverable exception thrown)"), this.getClass(), "on(ActionDomainEvent)"); } if(getSubscriberBehaviour() == DemoBehaviour.ANY_EXECUTE_VETO_WITH_NON_RECOVERABLE_EXCEPTION) { throw new NonRecoverableException( TranslatableString.tr("Rejecting event (non-recoverable exception thrown)"), this.getClass(), "on(ActionDomainEvent)"); } if(getSubscriberBehaviour() == DemoBehaviour.ANY_EXECUTE_VETO_WITH_OTHER_EXCEPTION) { throw new RuntimeException("Throwing some other exception"); } } //endregion
throw new NonRecoverableException("Cannot create link to " + titleService.titleOf(polymorphicReference) + ", no subtype provided"); throw new NonRecoverableException("Link's polymorphic reference " + titleService.titleOf(polymorphicReference) + " is not persistent");
@Action( semantics = SemanticsOf.SAFE, restrictTo = RestrictTo.PROTOTYPING ) public void demoException( final DemoExceptionType type) { switch(type) { case NON_RECOVERABLE_EXCEPTION: throw new NonRecoverableException("Demo throwing " + type.name()); case RECOVERABLE_EXCEPTION: throw new RecoverableException("Demo throwing " + type.name()); case RECOVERABLE_EXCEPTION_AUTO_ESCALATED: try { // this will trigger an exception (because category cannot be null), causing the xactn to be aborted setCategory(null); transactionService.flushTransaction(); } catch(final Exception e) { // it's a programming mistake to throw only a recoverable exception here, because of the xactn's state. // the framework should instead auto-escalate this to a non-recoverable exception throw new RecoverableException("Demo throwing " + type.name(), e); } } } //endregion