[2.2.1][P130807-00904] Fail to get the host of the uri which has only ? character...
authordahyeong.kim <dahyeong.kim@samsung.com>
Tue, 13 Aug 2013 07:26:23 +0000 (16:26 +0900)
committerdahyeong.kim <dahyeong.kim@samsung.com>
Wed, 14 Aug 2013 13:14:17 +0000 (22:14 +0900)
Change-Id: I59d436df7e9702bc74734dacad9fe8d762cfaf4d
Signed-off-by: dahyeong.kim <dahyeong.kim@samsung.com>
src/base/utility/FBaseUtilUri.cpp

index 4dda6df..eb62a9c 100644 (file)
@@ -86,15 +86,12 @@ Uri::SetUri(const Uri& uri)
 result
 Uri::SetUri(const Tizen::Base::String& str)
 {
-       SysTryReturn(NID_BASE_UTIL, str.GetLength() > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. An empty String.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturnResult(NID_BASE_UTIL, str.GetLength() > 0, E_INVALID_ARG, "Invalid argument is used. An empty String.");
 
        Clear();
 
        result r = ParseUri(str);
-       if (IsFailed(r))
-       {
-               return r;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_INVALID_FORMAT, "Translating [%s] into [%s].", GetErrorMessage(r), GetErrorMessage(E_INVALID_FORMAT));
 
        return E_SUCCESS;
 }
@@ -611,17 +608,10 @@ Uri::ParseAuthority(Uri& uri)
 
        Uri tempUri;
        r = tempUri.SetUri(str);
-
-       if (IsFailed(r))
-       {
-               return r;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
        r = ParseServerAuthority(str, tempUri.__host, tempUri.__userInfo, tempUri.__port);
-       if (IsFailed(r))
-       {
-               return r;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
        uri = tempUri;
 
@@ -920,47 +910,27 @@ Uri::SetUri(const Tizen::Base::String& scheme, const Tizen::Base::String& opaque
        {
                // Check that an extracted scheme is satisfied with RFC2396.
                bool isScheme = VerifyScheme(scheme);
-               if (!isScheme)
-               {
-                       r = E_INVALID_FORMAT;
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, isScheme, E_INVALID_FORMAT, "The scheme is invalid.");
 
                r = strbuf.Append(scheme);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append the scheme.");
 
                r = strbuf.Append(L':');
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append L':'.");
        }
 
        r = AppendSchemeSpecificPart(strbuf, opaque, authority, userInfo, host, port, path, query);
-       if (IsFailed(r))
-       {
-               goto CATCH;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
        r = AppendFragment(strbuf, fragment);
-       if (IsFailed(r))
-       {
-               goto CATCH;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
        fullUri = strbuf;
 
        r = SetUri(fullUri);
-       if (IsFailed(r))
-       {
-               goto CATCH;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to set the uri.");
 
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 result
@@ -973,99 +943,50 @@ Uri::AppendSchemeSpecificPart(Tizen::Base::String& strbuf, const Tizen::Base::St
        // Opaque part
        if (!opaque.IsEmpty())
        {
-               if (VerifyUriChar(opaque))
-               {
-                       r = strbuf.Append(opaque);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
-               }
-               else
-               {
-                       r = E_INVALID_FORMAT;
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, VerifyUriChar(opaque), E_INVALID_FORMAT, "The opaque is invalid.");
+               r = strbuf.Append(opaque);
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append opaque.");
        }
        else
        {
                r = AppendAuthority(strbuf, authority, userInfo, host, port);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append the authority.");
 
                if (!path.IsEmpty())
                {
-                       if (VerifyPath(path))
-                       {
-                               r = strbuf.Append(path);
-                       }
-                       else
-                       {
-                               r = E_INVALID_FORMAT;
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, VerifyPath(path), E_INVALID_FORMAT, "The path is invalid.");
+                       r = strbuf.Append(path);
                }
 
                if (!query.IsEmpty())
                {
-                       if (VerifyUriChar(query))
-                       {
-                               r = strbuf.Append(L'?');
-                               if (IsFailed(r))
-                               {
-                                       goto CATCH;
-                               }
+                       SysTryReturnResult(NID_BASE_UTIL, VerifyUriChar(query), E_INVALID_FORMAT, "The query is invalid.");
+                       r = strbuf.Append(L'?');
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append L'?'.");
 
-                               r = strbuf.Append(query);
-                               if (IsFailed(r))
-                               {
-                                       goto CATCH;
-                               }
-                       }
-                       else
-                       {
-                               r = E_INVALID_FORMAT;
-                               goto CATCH;
-                       }
+                       r = strbuf.Append(query);
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append the query.");
                }
        }
 
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 result
 Uri::AppendFragment(Tizen::Base::String& strbuf, const Tizen::Base::String& fragment) const
 {
-       result r = E_SUCCESS;
        if (!fragment.IsEmpty())
        {
-               bool isFragment = VerifyUriChar(fragment);
-               if (isFragment)
-               {
-                       r = strbuf.Append(L'#');
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+               SysTryReturnResult(NID_BASE_UTIL, VerifyUriChar(fragment), E_INVALID_FORMAT, "The fragment is invalid.");
 
-                       r = strbuf.Append(fragment);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
-               }
-               else
-               {
-                       r = E_INVALID_FORMAT;
-                       goto CATCH;
-               }
+               result r = strbuf.Append(L'#');
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append L'#'.");
+
+               r = strbuf.Append(fragment);
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append the fragment.");
        }
 
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 result
@@ -1080,42 +1001,20 @@ Uri::AppendAuthority(Tizen::Base::String& strbuf, const Tizen::Base::String& aut
        if (!host.IsEmpty())
        {
                // Check the Host
-               bool isHost = VerifyHost(host);
-               if (!isHost)
-               {
-                       r = E_INVALID_FORMAT;
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, VerifyHost(host), E_INVALID_FORMAT, "The host is invalid.");
 
                r = strbuf.Append(doubleSlash);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append the doubleSlash.");
 
                // Check the Userinfo
                if (!userInfo.IsEmpty())
                {
-                       bool user = VerifyUserInfo(userInfo);
-                       if (user)
-                       {
-                               r = strbuf.Append(userInfo);
-                               if (IsFailed(r))
-                               {
-                                       goto CATCH;
-                               }
+                       SysTryReturnResult(NID_BASE_UTIL, VerifyUserInfo(userInfo), E_INVALID_FORMAT, "The userInfo is invalid.");
+                       r = strbuf.Append(userInfo);
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append the userInfo.");
 
-                               r = strbuf.Append(L'@');
-                               if (IsFailed(r))
-                               {
-                                       goto CATCH;
-                               }
-                       }
-                       else
-                       {
-                               r = E_INVALID_FORMAT;
-                               goto CATCH;
-                       }
+                       r = strbuf.Append(L'@');
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append L'@'.");
                }
 
                int indexOf = 0;
@@ -1141,77 +1040,44 @@ Uri::AppendAuthority(Tizen::Base::String& strbuf, const Tizen::Base::String& aut
                if (needBracket)
                {
                        r = strbuf.Append(L'[');
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append L'['.");
                }
 
                r = strbuf.Append(host);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append the host.");
 
                if (needBracket)
                {
                        r = strbuf.Append(L']');
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append L']'.");
                }
 
                // Check the port
+               const int UNDEFINED_PORT = -1;
                if (port >= 0)
                {
                        r = strbuf.Append(L':');
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append L':'.");
 
                        r = strbuf.Append(port);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append the port.");
                }
-               else
+               else if (port != UNDEFINED_PORT)
                {
-                       if (port != -1)
-                       {
-                               r = E_INVALID_FORMAT;
-                               goto CATCH;
-                       }
+                       return E_INVALID_FORMAT;
                }
        }
        else if (!authority.IsEmpty())
        {
                r = strbuf.Append(doubleSlash);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append the doubleSlash.");
 
-               bool auth = VerifyAuthority(authority);
-               if (auth)
-               {
-                       r = strbuf.Append(authority);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
-               }
-               else
-               {
-                       r = E_INVALID_FORMAT;
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, VerifyAuthority(authority), E_INVALID_FORMAT, "The authority is invalid.");
+               r = strbuf.Append(authority);
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Failed to append the authority.");
        }
 
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 //
@@ -1239,7 +1105,7 @@ Uri::ParseUri(const Tizen::Base::String& str)
        ////////////////////////////////////////////////////////////////
 
        // Check the space
-       SysTryReturn(NID_BASE_UTIL, str[0] != L' ', E_INVALID_FORMAT, E_INVALID_FORMAT, "[%s] Invalid Scheme.", GetErrorMessage(E_INVALID_FORMAT));
+       SysTryReturnResult(NID_BASE_UTIL, str[0] != L' ', E_INVALID_FORMAT, "Invalid Scheme.");
 
        // Get a index of ':'
        r = str.IndexOf(colon, 0, indexOf);
@@ -1248,12 +1114,10 @@ Uri::ParseUri(const Tizen::Base::String& str)
                // There is a scheme componenet.
                String scheme;
                r = str.SubString(0, indexOf, scheme);
-               SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                // Check that an extracted scheme is satisfied with RFC2396.
-               bool isScheme = VerifyScheme(scheme);
-
-               SysTryReturn(NID_BASE_UTIL, isScheme, E_INVALID_FORMAT, E_INVALID_FORMAT, "[%s] Invalid Scheme.", GetErrorMessage(E_INVALID_FORMAT));
+               SysTryReturnResult(NID_BASE_UTIL, VerifyScheme(scheme), E_INVALID_FORMAT, "Invalid Scheme.");
 
                curIndex = indexOf;
                __scheme = scheme;
@@ -1272,29 +1136,19 @@ Uri::ParseUri(const Tizen::Base::String& str)
        if (__hasScheme) // This URI has a scheme.
        {
                startSsp = ++curIndex; // skip ':'
-               if (startSsp >= lengthOfUri)
-               {
-                       r = E_INVALID_FORMAT;
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, startSsp < lengthOfUri, E_INVALID_FORMAT, "startSsp must be less than lengthOfUri.");
 
                if (str[startSsp] == '/')
                {
                        // Hierarchical URI
                        r = ParseHierarchicalUri(str, startSsp, authority, path, query, curIndex);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                        SetAndEncodeAuthority(authority, path, query);
 
                        String ssp;
                        r = str.SubString(startSsp, curIndex - startSsp, ssp);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                        if (IsEncoded(ssp))
                        {
@@ -1317,28 +1171,20 @@ Uri::ParseUri(const Tizen::Base::String& str)
                        if (startFragment > curIndex && r == E_SUCCESS)
                        {
                                r = str.SubString(startSsp, startFragment - curIndex, ssp);
-                               if (IsFailed(r))
-                               {
-                                       goto CATCH;
-                               }
+                               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                        }
                        else if (r == E_OBJ_NOT_FOUND)
                        {
                                startFragment = 0;
                                r = str.SubString(startSsp, lengthOfUri - curIndex, ssp);
-                               if (IsFailed(r))
-                               {
-                                       goto CATCH;
-                               }
+                               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                        }
                        else
                        {
-                               goto CATCH;
+                               return r;
                        }
 
-                       bool isOpaque = VerifyUriChar(ssp);
-
-                       SysTryReturn(NID_BASE_UTIL, isOpaque, E_INVALID_FORMAT, E_INVALID_FORMAT, "[%s] Invalid Opaque URI.", GetErrorMessage(E_INVALID_FORMAT));
+                       SysTryReturnResult(NID_BASE_UTIL, VerifyUriChar(ssp), E_INVALID_FORMAT, "Invalid Opaque URI.");
 
                        // Opaque URI is not subject to further parsing.
                        if (IsEncoded(ssp))
@@ -1362,14 +1208,9 @@ Uri::ParseUri(const Tizen::Base::String& str)
 
                        startFragment++;
                        r = str.SubString(startFragment, lengthOfUri - startFragment, fragment);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
-
-                       bool isFragment = VerifyUriChar(fragment);
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
-                       SysTryReturn(NID_BASE_UTIL, isFragment, E_INVALID_FORMAT, E_INVALID_FORMAT, "[%s] Invalid Fragment.", GetErrorMessage(E_INVALID_FORMAT));
+                       SysTryReturnResult(NID_BASE_UTIL, VerifyUriChar(fragment), E_INVALID_FORMAT, "Invalid Fragment.");
 
                        if (IsEncoded(fragment))
                        {
@@ -1390,17 +1231,11 @@ Uri::ParseUri(const Tizen::Base::String& str)
                startSsp = 0;
 
                r = ParseHierarchicalUri(str, startSsp, authority, path, query, curIndex);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                String ssp;
                r = str.SubString(startSsp, curIndex - startSsp, ssp);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                if (IsEncoded(ssp))
                {
@@ -1428,10 +1263,7 @@ Uri::ParseUri(const Tizen::Base::String& str)
 
                String newAuth;
                r = ParseAuthority(authority, curIndex, newAuth, userInfo, host, port);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                if (!userInfo.IsEmpty())
                {
@@ -1464,15 +1296,13 @@ Uri::ParseUri(const Tizen::Base::String& str)
                startFragment++;
                String fragment;
 
-               r = str.SubString(startFragment, lengthOfUri - startFragment, fragment);
-               if (IsFailed(r))
+               if (startFragment < lengthOfUri)
                {
-                       goto CATCH;
+                       r = str.SubString(startFragment, lengthOfUri - startFragment, fragment);
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
-               bool isFragment = VerifyUriChar(fragment);
-
-               SysTryReturn(NID_BASE_UTIL, isFragment, E_INVALID_FORMAT, E_INVALID_FORMAT, "[%s] Invalid Fragment.", GetErrorMessage(E_INVALID_FORMAT));
+               SysTryReturnResult(NID_BASE_UTIL, VerifyUriChar(fragment), E_INVALID_FORMAT, "Invalid Fragment.");
 
                if (IsEncoded(fragment))
                {
@@ -1488,18 +1318,9 @@ Uri::ParseUri(const Tizen::Base::String& str)
                curIndex += fragment.GetLength() + 1; // skip '#'
        }
 
-       if (curIndex < lengthOfUri)
-       {
-               // Invalid URI format
-               r = E_INVALID_FORMAT;
-               goto CATCH;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, curIndex >= lengthOfUri, E_INVALID_FORMAT, "curIndex must be greater than or equal to lengthOfUri.");
 
-       // Convert Unicode string to UTF8 string when there is a wchar_t which is greater than 0x0080.
-       // authority fragment path query ssp
-       //EncodeAllComponent();
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 void
@@ -1569,7 +1390,6 @@ Uri::ParseHierarchicalUri(const Tizen::Base::String& str, int startSsp, Tizen::B
        String doubleSlash(L"//");
 
        int position = 0;
-       bool isPath = false;
        int temp = -1;
 
        bool startsWith = str.StartsWith(doubleSlash, curIndex);
@@ -1583,10 +1403,7 @@ Uri::ParseHierarchicalUri(const Tizen::Base::String& str, int startSsp, Tizen::B
                if (index > curIndex)
                {
                        r = str.SubString(curIndex, index - curIndex, authority);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
                }
                else if (index >= str.GetLength())
                {
@@ -1620,44 +1437,34 @@ Uri::ParseHierarchicalUri(const Tizen::Base::String& str, int startSsp, Tizen::B
        }
 
        r = str.SubString(curIndex, position - curIndex, tempPath);
-       if (IsFailed(r))
-       {
-               goto CATCH;
-       }
+       SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
 
-       isPath = VerifyPath(tempPath);
-       SysTryReturn(NID_BASE_UTIL, isPath, E_INVALID_FORMAT, E_INVALID_FORMAT, "[%s] Invalid Path.", GetErrorMessage(E_INVALID_FORMAT));
+       SysTryReturnResult(NID_BASE_UTIL, VerifyPath(tempPath), E_INVALID_FORMAT, "Invalid Path.");
 
        path = tempPath;
 
        curIndex = position;
 
-       if (curIndex < str.GetLength() && str[curIndex] == L'?')
+       // If there is no query after question-mark "?", this method returns E_SUCCESS and saves empty string as query.
+       if (str[curIndex] == L'?' && ++curIndex < str.GetLength())
        {
                String tempQuery;
 
-               curIndex++;
                int indexOf = 0;
                r = str.IndexOf(L'#', curIndex, indexOf);
                if (r == E_SUCCESS)
                {
                        r = str.SubString(curIndex, indexOf - curIndex, tempQuery);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
                }
                else if (r == E_OBJ_NOT_FOUND)
                {
                        r = str.SubString(curIndex, tempQuery);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryCatch(NID_BASE_UTIL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
                }
                else
                {
-                       goto CATCH;
+                       SysTryCatch(NID_BASE_UTIL, false, , r, "[%s] Propagating.", GetErrorMessage(r));
                }
 
                bool isQuery = VerifyUriChar(tempQuery);
@@ -1696,10 +1503,7 @@ Uri::ParseAuthority(const Tizen::Base::String& str, int curIndex, Tizen::Base::S
        if (isServerChar)
        {
                r = ParseServerAuthority(str, userInfo, host, port);
-               if (IsFailed(r))
-               {
-                       return r;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                newAuth = str;
        }
@@ -1729,14 +1533,9 @@ Uri::ParseServerAuthority(const Tizen::Base::String& str, Tizen::Base::String& u
        if (r == E_SUCCESS)
        {
                r = str.SubString(0, indexOf, userInfo);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
-
-               bool isUser = VerifyUserInfo(userInfo);
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
-               SysTryReturn(NID_BASE_UTIL, isUser, E_INVALID_FORMAT, E_INVALID_FORMAT, "[%s] Invalid UserInfo.", GetErrorMessage(E_INVALID_FORMAT));
+               SysTryReturnResult(NID_BASE_UTIL, VerifyUserInfo(userInfo), E_INVALID_FORMAT, "Invalid UserInfo.");
 
                user = userInfo;
 
@@ -1755,18 +1554,12 @@ Uri::ParseServerAuthority(const Tizen::Base::String& str, Tizen::Base::String& u
                int count = 0;
 
                r = ParseIpv4(str, index, count); // length of ipv4 string
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                if (count >= 0)
                {
                        r = str.SubString(0, count, ip4);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                        host = ip4;
                }
@@ -1776,10 +1569,7 @@ Uri::ParseServerAuthority(const Tizen::Base::String& str, Tizen::Base::String& u
                        String tmpHost;
 
                        r = ParseHostName(str, index, tmpHost);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                        host = tmpHost;
                }
@@ -1802,29 +1592,19 @@ Uri::ParseServerAuthority(const Tizen::Base::String& str, Tizen::Base::String& u
                if (r == E_SUCCESS)
                {
                        r = str.SubString(index, indexOf - index, tmpPort);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
                else if (r == E_OBJ_NOT_FOUND)
                {
                        r = str.SubString(index, tmpPort);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                int tmpPortLen = tmpPort.GetLength();
                for (int i = 0; i < tmpPortLen; i++)
                {
                        wchar_t ch = tmpPort[i];
-                       if (!(Character::IsDigit(ch)))
-                       {
-                               r = E_INVALID_FORMAT;
-                               goto CATCH;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, Character::IsDigit(ch), E_INVALID_FORMAT, "The character is not a digit.");
                }
                index += tmpPort.GetLength();
 
@@ -1837,16 +1617,9 @@ Uri::ParseServerAuthority(const Tizen::Base::String& str, Tizen::Base::String& u
                port = -1;
        }
 
-       if (index < (int) str.GetLength())
-       {
-               r = E_INVALID_FORMAT;
-               goto CATCH;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, index >= str.GetLength(), E_INVALID_FORMAT, "index must be greater than or equal to str.GetLength().");
 
        return E_SUCCESS;
-
-CATCH:
-       return r;
 }
 
 //
@@ -1857,26 +1630,19 @@ Uri::ParseHostName(const Tizen::Base::String& str, int index, Tizen::Base::Strin
 {
        result r = E_SUCCESS;
        int indexOf = 0;
-       bool isHost = false;
 
        int strLen = str.GetLength();
        r = str.IndexOf(L':', index, indexOf);
        if (r == E_SUCCESS)
        {
                r = str.SubString(index, indexOf - index, host);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
        }
        else if (r == E_OBJ_NOT_FOUND)
        {
                //host = str;
                r = str.SubString(index, host);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
        }
 
        for (int i = 0; i < strLen; i++)
@@ -1896,12 +1662,9 @@ Uri::ParseHostName(const Tizen::Base::String& str, int index, Tizen::Base::Strin
                }
        }
 
-       isHost = VerifyHost(host);
-
-       SysTryReturn(NID_BASE_UTIL, isHost, E_INVALID_FORMAT, E_INVALID_FORMAT, "[%s] Invalid Host.", GetErrorMessage(E_INVALID_FORMAT));
+       SysTryReturnResult(NID_BASE_UTIL, VerifyHost(host), E_INVALID_FORMAT, "Invalid Host.");
 
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 //
@@ -1935,10 +1698,7 @@ Uri::ParseIpv4(const Tizen::Base::String& str, int start, int& count)
        String ipHost;
 
        r = str.SubString(start, ipHost);
-       if (IsFailed(r))
-       {
-               return r;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
        // Set the index as an end position of ipv4
        count = ipHost.GetLength();
@@ -1953,39 +1713,29 @@ Uri::ParseIpv4(const Tizen::Base::String& str, int start, int& count)
                if (ch != L'.' && !(Character::IsDigit(ch)))
                {
                        count = -1;
-                       goto CATCH;
+                       return E_SUCCESS;
                }
        }
 
-       while (strTok.HasMoreTokens() == true)
+       while (strTok.HasMoreTokens())
        {
                String token;
 
                r = strTok.GetNextToken(token);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                int ret = 0;
                r = Integer::Parse(token, 10, ret);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                // each part of IPv4 address cannot exceed 255.
                if (ret < 0 || ret > 255)
                {
-                       r = E_INVALID_FORMAT;
-                       goto CATCH;
+                       return E_INVALID_FORMAT;
                }
        }
 
        return E_SUCCESS;
-
-CATCH:
-       return r;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -2400,10 +2150,7 @@ Uri::Decode(const Tizen::Base::String& str)
 
                        short ret = 0;
                        r = Short::Parse(utf8Str, 16, ret);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, str, r, "[%s] Propagating.", GetErrorMessage(r));
 
                        r = bb.SetByte((byte) ret);
 
@@ -2430,9 +2177,6 @@ Uri::Decode(const Tizen::Base::String& str)
        }
 
        return decodedBuf;
-
-CATCH:
-       return str;
 }
 
 //
@@ -2446,11 +2190,10 @@ Uri::Encode(const Tizen::Base::String& str) const
                return str;
        }
 
-       result r = E_SUCCESS;
        String upper;
        WcharBuffer wchar_tBuf;
 
-       r = wchar_tBuf.Construct(str.GetLength() + 1);
+       result r = wchar_tBuf.Construct(str.GetLength() + 1);
 
        String strbuf;
 
@@ -2542,31 +2285,18 @@ Uri::AppendEscape(Tizen::Base::String& strbuf, byte b)
        byte bt1 = '\0';
        byte bt2 = '\0';
 
-       result r = E_SUCCESS;
-       r = strbuf.Append(L'%');
-       if (IsFailed(r))
-       {
-               goto CATCH;
-       }
+       result r = strbuf.Append(L'%');
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
        bt1 = (b >> 4) & 0x0f;
        r = strbuf.Append(HEX_DIGITS[bt1]);
-       if (IsFailed(r))
-       {
-               goto CATCH;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
        bt2 = (b >> 0) & 0x0f;
        r = strbuf.Append(HEX_DIGITS[bt2]);
-       if (IsFailed(r))
-       {
-               goto CATCH;
-       }
-
-       return r;
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
-CATCH:
-       return r;
+       return E_SUCCESS;
 }
 
 // This method compares str1 and str2 after replacing all uppercase letters with their lowercase letters
@@ -3013,37 +2743,25 @@ Uri::Resolve(const Uri& baseUri, const Uri& childUri, Uri& resultUri)
                if (!baseUri.__scheme.IsEmpty())
                {
                        r = resultUri.SetScheme(baseUri.__scheme);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                if (!baseUri.__authority.IsEmpty())
                {
                        r = resultUri.SetAuthority(baseUri.__authority);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                if (!baseUri.__userInfo.IsEmpty())
                {
                        r = resultUri.SetUserInfo(baseUri.__userInfo);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                if (!baseUri.__host.IsEmpty())
                {
                        r = resultUri.SetHost(baseUri.__host);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                resultUri.SetPort(baseUri.__port);
@@ -3051,28 +2769,19 @@ Uri::Resolve(const Uri& baseUri, const Uri& childUri, Uri& resultUri)
                if (!baseUri.__path.IsEmpty())
                {
                        r = resultUri.SetPath(baseUri.__path);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                if (!childUri.__fragment.IsEmpty())
                {
                        r = resultUri.SetFragment(childUri.__fragment);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                if (!baseUri.__query.IsEmpty())
                {
                        r = resultUri.SetQuery(baseUri.__query);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                return E_SUCCESS;
@@ -3088,28 +2797,19 @@ Uri::Resolve(const Uri& baseUri, const Uri& childUri, Uri& resultUri)
        if (!baseUri.__scheme.IsEmpty())
        {
                r = resultUri.SetScheme(baseUri.__scheme);
-               if (IsFailed(r))
-               {
-                       return r;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
        }
 
        if (!childUri.__query.IsEmpty())
        {
                r = resultUri.SetQuery(childUri.__query);
-               if (IsFailed(r))
-               {
-                       return r;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
        }
 
        if (!childUri.__fragment.IsEmpty())
        {
                r = resultUri.SetFragment(childUri.__fragment);
-               if (IsFailed(r))
-               {
-                       return r;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
        }
 
        // 5.2(4) Authority
@@ -3118,28 +2818,19 @@ Uri::Resolve(const Uri& baseUri, const Uri& childUri, Uri& resultUri)
                if (!baseUri.__authority.IsEmpty())
                {
                        r = resultUri.SetAuthority(baseUri.__authority);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                if (!baseUri.__host.IsEmpty())
                {
                        r = resultUri.SetHost(baseUri.__host);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                if (!baseUri.__userInfo.IsEmpty())
                {
                        r = resultUri.SetUserInfo(baseUri.__userInfo);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                resultUri.SetPort(baseUri.__port);
@@ -3157,10 +2848,7 @@ Uri::Resolve(const Uri& baseUri, const Uri& childUri, Uri& resultUri)
                        if (!encodedPath.IsEmpty())
                        {
                                r = resultUri.SetPath(encodedPath);
-                               if (IsFailed(r))
-                               {
-                                       return r;
-                               }
+                               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                        }
                }
                else
@@ -3176,10 +2864,7 @@ Uri::Resolve(const Uri& baseUri, const Uri& childUri, Uri& resultUri)
                                }
 
                                r = resultUri.SetPath(relPath);
-                               if (IsFailed(r))
-                               {
-                                       return r;
-                               }
+                               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                        }
                }
        }
@@ -3188,28 +2873,19 @@ Uri::Resolve(const Uri& baseUri, const Uri& childUri, Uri& resultUri)
                if (!childUri.__authority.IsEmpty())
                {
                        r = resultUri.SetAuthority(childUri.__authority);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                if (!childUri.__host.IsEmpty())
                {
                        r = resultUri.SetHost(childUri.__host);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                if (!childUri.__userInfo.IsEmpty())
                {
                        r = resultUri.SetUserInfo(childUri.__userInfo);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
 
                resultUri.SetPort(childUri.__port);
@@ -3217,10 +2893,7 @@ Uri::Resolve(const Uri& baseUri, const Uri& childUri, Uri& resultUri)
                if (!childUri.__path.IsEmpty())
                {
                        r = resultUri.SetPath(childUri.__path);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
                }
        }
 
@@ -3244,10 +2917,7 @@ Uri::ResolvePath(const String& basePath, const String& childPath, bool isAbsolut
                if (indexOf >= 0 && r == E_SUCCESS)
                {
                        r = basePath.SubString(0, indexOf + 1, path);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r));
                }
        }
        // 5.2 (6a)
@@ -3259,32 +2929,19 @@ Uri::ResolvePath(const String& basePath, const String& childPath, bool isAbsolut
                {
                        String tmpath;
                        r = basePath.SubString(0, indexOf + 1, tmpath);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r));
 
                        r = strbuf.Append(tmpath);
-                       if (IsFailed(r))
-                       {
-                               goto CATCH;
-                       }
+                       SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r));
                }
 
                r = strbuf.Append(childPath);
-               if (IsFailed(r))
-               {
-                       goto CATCH;
-               }
+               SysTryReturn(NID_BASE_UTIL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r));
 
                path = strbuf;
        }
 
        return InternalNormalize(path);
-
-CATCH:
-       SetLastResult(r);
-       return null;
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -3329,10 +2986,7 @@ Uri::Relativize(const Uri& baseUri, const Uri& childUri, Uri& resultUri)
                        String strbuf(basePath);
 
                        r = strbuf.Append(slash);
-                       if (IsFailed(r))
-                       {
-                               return r;
-                       }
+                       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
                        newBp = strbuf;
                }
@@ -3352,33 +3006,21 @@ Uri::Relativize(const Uri& baseUri, const Uri& childUri, Uri& resultUri)
 
        String path;
        r = childPath.SubString(basePath.GetLength(), path);
-       if (IsFailed(r))
-       {
-               return E_SUCCESS;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, E_SUCCESS, "Translating [%s] into [%s].", GetErrorMessage(r), GetErrorMessage(E_SUCCESS));
 
        r = resultUri.SetPath(path);
-       if (IsFailed(r))
-       {
-               return r;
-       }
+       SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
 
        if (!childUri.__query.IsEmpty())
        {
                r = resultUri.SetQuery(childUri.__query);
-               if (IsFailed(r))
-               {
-                       return r;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
        }
 
        if (!childUri.__fragment.IsEmpty())
        {
                r = resultUri.SetFragment(childUri.__fragment);
-               if (IsFailed(r))
-               {
-                       return r;
-               }
+               SysTryReturnResult(NID_BASE_UTIL, r == E_SUCCESS, r, "Propagating.");
        }
 
        return r;
@@ -3481,4 +3123,4 @@ Uri::Clear(void)
        __encodedQuery.Clear();
        __encodedSsp.Clear();
 }
-}}} // Tizen::Base::Utility
\ No newline at end of file
+}}} // Tizen::Base::Utility