From 7db7fbe3c20a2ae7ec237b6da6c5d9852e781d1c Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 22 May 2013 15:51:23 +0200 Subject: [PATCH] Add exception to LinphoneFactory.createAddress --- java/common/org/linphone/core/LinphoneCoreFactory.java | 3 ++- java/impl/org/linphone/core/LinphoneAddressImpl.java | 5 ++++- java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/java/common/org/linphone/core/LinphoneCoreFactory.java b/java/common/org/linphone/core/LinphoneCoreFactory.java index 5e8637999..88aa4343f 100644 --- a/java/common/org/linphone/core/LinphoneCoreFactory.java +++ b/java/common/org/linphone/core/LinphoneCoreFactory.java @@ -81,8 +81,9 @@ abstract public class LinphoneCoreFactory { * Constructs a LinphoneAddress object by parsing the user supplied address, given as a string. * @param address should be like sip:joe@sip.linphone.org * @return + * @throws LinphoneCoreException if address cannot be parsed */ - abstract public LinphoneAddress createLinphoneAddress(String address); + abstract public LinphoneAddress createLinphoneAddress(String address) throws LinphoneCoreException; abstract public LpConfig createLpConfig(String file); abstract public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException; diff --git a/java/impl/org/linphone/core/LinphoneAddressImpl.java b/java/impl/org/linphone/core/LinphoneAddressImpl.java index 000ae52ab..66bfa085f 100644 --- a/java/impl/org/linphone/core/LinphoneAddressImpl.java +++ b/java/impl/org/linphone/core/LinphoneAddressImpl.java @@ -34,8 +34,11 @@ public class LinphoneAddressImpl implements LinphoneAddress { private native void setUserName(long ptr,String username); private native String toString(long ptr); - protected LinphoneAddressImpl(String identity) { + protected LinphoneAddressImpl(String identity) throws LinphoneCoreException{ nativePtr = newLinphoneAddressImpl(identity, null); + if(nativePtr==0) { + throw new LinphoneCoreException("Cannot create LinphoneAdress from ["+identity+"]"); + } } protected LinphoneAddressImpl(String username,String domain,String displayName) { diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index 8cedba445..d1bef5bf6 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -102,7 +102,7 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } @Override - public LinphoneAddress createLinphoneAddress(String identity) { + public LinphoneAddress createLinphoneAddress(String identity) throws LinphoneCoreException { return new LinphoneAddressImpl(identity); }