{"action":"created","comment":{"url":"https://api.github.com/repos/paypal/squbs/pulls/comments/67804812","id":67804812,"diff_hunk":"@@ -22,37 +22,46 @@ import com.typesafe.config.{Config, ConfigException, ConfigMemorySize}\n import scala.collection.JavaConversions._\n import scala.concurrent.duration._\n import scala.reflect.runtime.universe._\n+import scala.util.{Failure, Success, Try}\n \n object ConfigUtil {\n \n   private val StringTag = typeTag[String]\n   private val StringListTag = typeTag[Seq[String]]\n   private val ConfigTag = typeTag[Config]\n   private val ConfigListTag = typeTag[Seq[Config]]\n-  private val DurationTag = typeTag[FiniteDuration]\n+  private val DurationTag = typeTag[Duration]\n+  private val FiniteDurationTag = typeTag[FiniteDuration]\n   private val ConfigMemorySizeTag = typeTag[ConfigMemorySize]\n \n   implicit class RichConfig(val underlying: Config) extends AnyVal {\n \n-    def getOption[T](path: String)(implicit tag: TypeTag[T]): Option[T] =\n-      if (underlying.hasPath(path))\n-        (tag match {\n-            case StringTag => Some(underlying.getString(path))\n-            case StringListTag => Some(underlying.getStringList(path).toSeq)\n-            case TypeTag.Int => Some(underlying.getInt(path))\n-            case TypeTag.Boolean => Some(underlying.getBoolean(path))\n-            case TypeTag.Double => Some(underlying.getDouble(path))\n-            case ConfigTag => Some(underlying.getConfig(path))\n-            case ConfigListTag => Some(underlying.getConfigList(path).toSeq)\n-            case DurationTag => Some(Duration.create(underlying.getDuration(path, MILLISECONDS), MILLISECONDS))\n-            case ConfigMemorySizeTag => Some(underlying.getMemorySize(path))\n-            case _ => throw new IllegalArgumentException(s\"Configuration option type $tag not implemented\")\n-          }).asInstanceOf[Option[T]]\n-      else None\n+    def getTry[T](path: String)(implicit tag: TypeTag[T]): Try[T] = Try {\n+      (tag match {\n+        case StringTag => underlying.getString(path)\n+        case StringListTag => underlying.getStringList(path).toSeq\n+        case TypeTag.Int => underlying.getInt(path)\n+        case TypeTag.Boolean => underlying.getBoolean(path)\n+        case TypeTag.Double => underlying.getDouble(path)\n+        case ConfigTag => underlying.getConfig(path)\n+        case ConfigListTag => underlying.getConfigList(path).toSeq\n+        case FiniteDurationTag => Duration(underlying.getString(path)).asInstanceOf[FiniteDuration]","path":"squbs-pattern/src/main/scala/org/squbs/pattern/util/ConfigUtil.scala","position":51,"original_position":43,"commit_id":"4e7e8da538ca34f45c597a7c9812dd522c0dd10d","original_commit_id":"2d363cbc61e59631dfc32252ed9f8637c5a4bc3a","user":{"login":"dmartyanov","id":5476060,"avatar_url":"https://avatars.githubusercontent.com/u/5476060?v=3","gravatar_id":"","url":"https://api.github.com/users/dmartyanov","html_url":"https://github.com/dmartyanov","followers_url":"https://api.github.com/users/dmartyanov/followers","following_url":"https://api.github.com/users/dmartyanov/following{/other_user}","gists_url":"https://api.github.com/users/dmartyanov/gists{/gist_id}","starred_url":"https://api.github.com/users/dmartyanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmartyanov/subscriptions","organizations_url":"https://api.github.com/users/dmartyanov/orgs","repos_url":"https://api.github.com/users/dmartyanov/repos","events_url":"https://api.github.com/users/dmartyanov/events{/privacy}","received_events_url":"https://api.github.com/users/dmartyanov/received_events","type":"User","site_admin":false},"body":"I agree I always prefer to bring more order to the logic. \r\nOnly one comment just to keep it in mind: \r\nIf we recover `FiniteDuration` specific exceptions with `ConfigException.WrongType`,  we should do the same with `java.util.regex.PatternSyntaxException` for incorrect Regex string as well. That leads us to the situation when  `getTry` could return one of  4 options: `Success(value)`,  `Failure(IllegalArgumentException)`,  `Failure(ConfigException.Missing)` and `Failure(ConfigException.WrongType)` (like it is in `com.typesafe.config.Config`). \r\nLooks good to me. The changes have been committed.","created_at":"2016-06-21T03:59:05Z","updated_at":"2016-06-21T03:59:05Z","html_url":"https://github.com/paypal/squbs/pull/224#discussion_r67804812","pull_request_url":"https://api.github.com/repos/paypal/squbs/pulls/224","_links":{"self":{"href":"https://api.github.com/repos/paypal/squbs/pulls/comments/67804812"},"html":{"href":"https://github.com/paypal/squbs/pull/224#discussion_r67804812"},"pull_request":{"href":"https://api.github.com/repos/paypal/squbs/pulls/224"}}},"pull_request":{"url":"https://api.github.com/repos/paypal/squbs/pulls/224","id":74089043,"html_url":"https://github.com/paypal/squbs/pull/224","diff_url":"https://github.com/paypal/squbs/pull/224.diff","patch_url":"https://github.com/paypal/squbs/pull/224.patch","issue_url":"https://api.github.com/repos/paypal/squbs/issues/224","number":224,"state":"open","locked":false,"title":"140 ConfigUtil.getOptionalDuration changes time unit","user":{"login":"dmartyanov","id":5476060,"avatar_url":"https://avatars.githubusercontent.com/u/5476060?v=3","gravatar_id":"","url":"https://api.github.com/users/dmartyanov","html_url":"https://github.com/dmartyanov","followers_url":"https://api.github.com/users/dmartyanov/followers","following_url":"https://api.github.com/users/dmartyanov/following{/other_user}","gists_url":"https://api.github.com/users/dmartyanov/gists{/gist_id}","starred_url":"https://api.github.com/users/dmartyanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmartyanov/subscriptions","organizations_url":"https://api.github.com/users/dmartyanov/orgs","repos_url":"https://api.github.com/users/dmartyanov/repos","events_url":"https://api.github.com/users/dmartyanov/events{/privacy}","received_events_url":"https://api.github.com/users/dmartyanov/received_events","type":"User","site_admin":false},"body":"- added Duration typetag to unicomplex/ConfigUtil and pattern/ConfigUtil\r\n- added FiniteDuration typetag to unicomplex/ConfigUtil and pattern/ConfigUtil\r\n- added tests\r\n- refactored config calls","created_at":"2016-06-16T14:20:11Z","updated_at":"2016-06-21T03:59:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"40d00dbc2278b17f804390d807f1df9c8db8a316","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/paypal/squbs/pulls/224/commits","review_comments_url":"https://api.github.com/repos/paypal/squbs/pulls/224/comments","review_comment_url":"https://api.github.com/repos/paypal/squbs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/paypal/squbs/issues/224/comments","statuses_url":"https://api.github.com/repos/paypal/squbs/statuses/4e7e8da538ca34f45c597a7c9812dd522c0dd10d","head":{"label":"dmartyanov:master","ref":"master","sha":"4e7e8da538ca34f45c597a7c9812dd522c0dd10d","user":{"login":"dmartyanov","id":5476060,"avatar_url":"https://avatars.githubusercontent.com/u/5476060?v=3","gravatar_id":"","url":"https://api.github.com/users/dmartyanov","html_url":"https://github.com/dmartyanov","followers_url":"https://api.github.com/users/dmartyanov/followers","following_url":"https://api.github.com/users/dmartyanov/following{/other_user}","gists_url":"https://api.github.com/users/dmartyanov/gists{/gist_id}","starred_url":"https://api.github.com/users/dmartyanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmartyanov/subscriptions","organizations_url":"https://api.github.com/users/dmartyanov/orgs","repos_url":"https://api.github.com/users/dmartyanov/repos","events_url":"https://api.github.com/users/dmartyanov/events{/privacy}","received_events_url":"https://api.github.com/users/dmartyanov/received_events","type":"User","site_admin":false},"repo":{"id":60661611,"name":"squbs","full_name":"dmartyanov/squbs","owner":{"login":"dmartyanov","id":5476060,"avatar_url":"https://avatars.githubusercontent.com/u/5476060?v=3","gravatar_id":"","url":"https://api.github.com/users/dmartyanov","html_url":"https://github.com/dmartyanov","followers_url":"https://api.github.com/users/dmartyanov/followers","following_url":"https://api.github.com/users/dmartyanov/following{/other_user}","gists_url":"https://api.github.com/users/dmartyanov/gists{/gist_id}","starred_url":"https://api.github.com/users/dmartyanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmartyanov/subscriptions","organizations_url":"https://api.github.com/users/dmartyanov/orgs","repos_url":"https://api.github.com/users/dmartyanov/repos","events_url":"https://api.github.com/users/dmartyanov/events{/privacy}","received_events_url":"https://api.github.com/users/dmartyanov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dmartyanov/squbs","description":"Akka/Spray for Large-Scale Production Deployments","fork":true,"url":"https://api.github.com/repos/dmartyanov/squbs","forks_url":"https://api.github.com/repos/dmartyanov/squbs/forks","keys_url":"https://api.github.com/repos/dmartyanov/squbs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmartyanov/squbs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmartyanov/squbs/teams","hooks_url":"https://api.github.com/repos/dmartyanov/squbs/hooks","issue_events_url":"https://api.github.com/repos/dmartyanov/squbs/issues/events{/number}","events_url":"https://api.github.com/repos/dmartyanov/squbs/events","assignees_url":"https://api.github.com/repos/dmartyanov/squbs/assignees{/user}","branches_url":"https://api.github.com/repos/dmartyanov/squbs/branches{/branch}","tags_url":"https://api.github.com/repos/dmartyanov/squbs/tags","blobs_url":"https://api.github.com/repos/dmartyanov/squbs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmartyanov/squbs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmartyanov/squbs/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmartyanov/squbs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmartyanov/squbs/statuses/{sha}","languages_url":"https://api.github.com/repos/dmartyanov/squbs/languages","stargazers_url":"https://api.github.com/repos/dmartyanov/squbs/stargazers","contributors_url":"https://api.github.com/repos/dmartyanov/squbs/contributors","subscribers_url":"https://api.github.com/repos/dmartyanov/squbs/subscribers","subscription_url":"https://api.github.com/repos/dmartyanov/squbs/subscription","commits_url":"https://api.github.com/repos/dmartyanov/squbs/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmartyanov/squbs/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmartyanov/squbs/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmartyanov/squbs/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmartyanov/squbs/contents/{+path}","compare_url":"https://api.github.com/repos/dmartyanov/squbs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmartyanov/squbs/merges","archive_url":"https://api.github.com/repos/dmartyanov/squbs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmartyanov/squbs/downloads","issues_url":"https://api.github.com/repos/dmartyanov/squbs/issues{/number}","pulls_url":"https://api.github.com/repos/dmartyanov/squbs/pulls{/number}","milestones_url":"https://api.github.com/repos/dmartyanov/squbs/milestones{/number}","notifications_url":"https://api.github.com/repos/dmartyanov/squbs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmartyanov/squbs/labels{/name}","releases_url":"https://api.github.com/repos/dmartyanov/squbs/releases{/id}","deployments_url":"https://api.github.com/repos/dmartyanov/squbs/deployments","created_at":"2016-06-08T02:19:08Z","updated_at":"2016-06-08T02:19:09Z","pushed_at":"2016-06-21T03:40:23Z","git_url":"git://github.com/dmartyanov/squbs.git","ssh_url":"git@github.com:dmartyanov/squbs.git","clone_url":"https://github.com/dmartyanov/squbs.git","svn_url":"https://github.com/dmartyanov/squbs","homepage":"http://paypal.github.io/squbs","size":6088,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"paypal:master","ref":"master","sha":"ea92ef02987aba4bc3233190dcff5d67d2f4910e","user":{"login":"paypal","id":476675,"avatar_url":"https://avatars.githubusercontent.com/u/476675?v=3","gravatar_id":"","url":"https://api.github.com/users/paypal","html_url":"https://github.com/paypal","followers_url":"https://api.github.com/users/paypal/followers","following_url":"https://api.github.com/users/paypal/following{/other_user}","gists_url":"https://api.github.com/users/paypal/gists{/gist_id}","starred_url":"https://api.github.com/users/paypal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paypal/subscriptions","organizations_url":"https://api.github.com/users/paypal/orgs","repos_url":"https://api.github.com/users/paypal/repos","events_url":"https://api.github.com/users/paypal/events{/privacy}","received_events_url":"https://api.github.com/users/paypal/received_events","type":"Organization","site_admin":false},"repo":{"id":38714007,"name":"squbs","full_name":"paypal/squbs","owner":{"login":"paypal","id":476675,"avatar_url":"https://avatars.githubusercontent.com/u/476675?v=3","gravatar_id":"","url":"https://api.github.com/users/paypal","html_url":"https://github.com/paypal","followers_url":"https://api.github.com/users/paypal/followers","following_url":"https://api.github.com/users/paypal/following{/other_user}","gists_url":"https://api.github.com/users/paypal/gists{/gist_id}","starred_url":"https://api.github.com/users/paypal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paypal/subscriptions","organizations_url":"https://api.github.com/users/paypal/orgs","repos_url":"https://api.github.com/users/paypal/repos","events_url":"https://api.github.com/users/paypal/events{/privacy}","received_events_url":"https://api.github.com/users/paypal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/paypal/squbs","description":"Akka/Spray for Large-Scale Production Deployments","fork":false,"url":"https://api.github.com/repos/paypal/squbs","forks_url":"https://api.github.com/repos/paypal/squbs/forks","keys_url":"https://api.github.com/repos/paypal/squbs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paypal/squbs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paypal/squbs/teams","hooks_url":"https://api.github.com/repos/paypal/squbs/hooks","issue_events_url":"https://api.github.com/repos/paypal/squbs/issues/events{/number}","events_url":"https://api.github.com/repos/paypal/squbs/events","assignees_url":"https://api.github.com/repos/paypal/squbs/assignees{/user}","branches_url":"https://api.github.com/repos/paypal/squbs/branches{/branch}","tags_url":"https://api.github.com/repos/paypal/squbs/tags","blobs_url":"https://api.github.com/repos/paypal/squbs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paypal/squbs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paypal/squbs/git/refs{/sha}","trees_url":"https://api.github.com/repos/paypal/squbs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paypal/squbs/statuses/{sha}","languages_url":"https://api.github.com/repos/paypal/squbs/languages","stargazers_url":"https://api.github.com/repos/paypal/squbs/stargazers","contributors_url":"https://api.github.com/repos/paypal/squbs/contributors","subscribers_url":"https://api.github.com/repos/paypal/squbs/subscribers","subscription_url":"https://api.github.com/repos/paypal/squbs/subscription","commits_url":"https://api.github.com/repos/paypal/squbs/commits{/sha}","git_commits_url":"https://api.github.com/repos/paypal/squbs/git/commits{/sha}","comments_url":"https://api.github.com/repos/paypal/squbs/comments{/number}","issue_comment_url":"https://api.github.com/repos/paypal/squbs/issues/comments{/number}","contents_url":"https://api.github.com/repos/paypal/squbs/contents/{+path}","compare_url":"https://api.github.com/repos/paypal/squbs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paypal/squbs/merges","archive_url":"https://api.github.com/repos/paypal/squbs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paypal/squbs/downloads","issues_url":"https://api.github.com/repos/paypal/squbs/issues{/number}","pulls_url":"https://api.github.com/repos/paypal/squbs/pulls{/number}","milestones_url":"https://api.github.com/repos/paypal/squbs/milestones{/number}","notifications_url":"https://api.github.com/repos/paypal/squbs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paypal/squbs/labels{/name}","releases_url":"https://api.github.com/repos/paypal/squbs/releases{/id}","deployments_url":"https://api.github.com/repos/paypal/squbs/deployments","created_at":"2015-07-07T20:48:12Z","updated_at":"2016-06-19T13:10:06Z","pushed_at":"2016-06-21T03:40:23Z","git_url":"git://github.com/paypal/squbs.git","ssh_url":"git@github.com:paypal/squbs.git","clone_url":"https://github.com/paypal/squbs.git","svn_url":"https://github.com/paypal/squbs","homepage":"http://paypal.github.io/squbs","size":6132,"stargazers_count":84,"watchers_count":84,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":33,"mirror_url":null,"open_issues_count":30,"forks":33,"open_issues":30,"watchers":84,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/paypal/squbs/pulls/224"},"html":{"href":"https://github.com/paypal/squbs/pull/224"},"issue":{"href":"https://api.github.com/repos/paypal/squbs/issues/224"},"comments":{"href":"https://api.github.com/repos/paypal/squbs/issues/224/comments"},"review_comments":{"href":"https://api.github.com/repos/paypal/squbs/pulls/224/comments"},"review_comment":{"href":"https://api.github.com/repos/paypal/squbs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/paypal/squbs/pulls/224/commits"},"statuses":{"href":"https://api.github.com/repos/paypal/squbs/statuses/4e7e8da538ca34f45c597a7c9812dd522c0dd10d"}}}}
{"actor":{"display_login":"dmartyanov"}}