{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/rocksdb/issues/1250","repository_url":"https://api.github.com/repos/facebook/rocksdb","labels_url":"https://api.github.com/repos/facebook/rocksdb/issues/1250/labels{/name}","comments_url":"https://api.github.com/repos/facebook/rocksdb/issues/1250/comments","events_url":"https://api.github.com/repos/facebook/rocksdb/issues/1250/events","html_url":"https://github.com/facebook/rocksdb/issues/1250","id":168897948,"number":1250,"title":"Java API does not expose Status","user":{"login":"adamretter","id":1264057,"avatar_url":"https://avatars.githubusercontent.com/u/1264057?v=3","gravatar_id":"","url":"https://api.github.com/users/adamretter","html_url":"https://github.com/adamretter","followers_url":"https://api.github.com/users/adamretter/followers","following_url":"https://api.github.com/users/adamretter/following{/other_user}","gists_url":"https://api.github.com/users/adamretter/gists{/gist_id}","starred_url":"https://api.github.com/users/adamretter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamretter/subscriptions","organizations_url":"https://api.github.com/users/adamretter/orgs","repos_url":"https://api.github.com/users/adamretter/repos","events_url":"https://api.github.com/users/adamretter/events{/privacy}","received_events_url":"https://api.github.com/users/adamretter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/rocksdb/labels/java-api","name":"java-api","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"adamretter","id":1264057,"avatar_url":"https://avatars.githubusercontent.com/u/1264057?v=3","gravatar_id":"","url":"https://api.github.com/users/adamretter","html_url":"https://github.com/adamretter","followers_url":"https://api.github.com/users/adamretter/followers","following_url":"https://api.github.com/users/adamretter/following{/other_user}","gists_url":"https://api.github.com/users/adamretter/gists{/gist_id}","starred_url":"https://api.github.com/users/adamretter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamretter/subscriptions","organizations_url":"https://api.github.com/users/adamretter/orgs","repos_url":"https://api.github.com/users/adamretter/repos","events_url":"https://api.github.com/users/adamretter/events{/privacy}","received_events_url":"https://api.github.com/users/adamretter/received_events","type":"User","site_admin":false},"assignees":[{"login":"adamretter","id":1264057,"avatar_url":"https://avatars.githubusercontent.com/u/1264057?v=3","gravatar_id":"","url":"https://api.github.com/users/adamretter","html_url":"https://github.com/adamretter","followers_url":"https://api.github.com/users/adamretter/followers","following_url":"https://api.github.com/users/adamretter/following{/other_user}","gists_url":"https://api.github.com/users/adamretter/gists{/gist_id}","starred_url":"https://api.github.com/users/adamretter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamretter/subscriptions","organizations_url":"https://api.github.com/users/adamretter/orgs","repos_url":"https://api.github.com/users/adamretter/repos","events_url":"https://api.github.com/users/adamretter/events{/privacy}","received_events_url":"https://api.github.com/users/adamretter/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-08-02T14:21:23Z","updated_at":"2016-08-02T18:57:38Z","closed_at":null,"body":"The Java API does not expose information from the Status class which makes it difficult to diagnose the result of functions that can return an error status or an information status such as `Transaction::Get` with `Status::MergeInProgress`.\r\n\r\nAt the moment the Java API simply throws the checked exception `RocksDBException` when `!status.isOk()`.\r\n\r\nIn addition the current use of Checked Exceptions also mean that it is difficult/cumbersome to use the Java API with functional paradigms in Java 8.\r\n\r\nI see 4 possible options for improving the error handling in RocksJava:\r\n\r\n1. Add a `Status` class field to the `RocksDBException`, so that the caller has more information about the resultant state from a function call.\r\n\r\n2. Change `RocksDBException` to be an unchecked exception and (1).\r\n\r\n3. Remove exceptions entirely (Approach A) - Change the functions in RocksJava that can throw a `RocksDBException` to instead return a `Tuple<Status, T>`. All successful function calls will have a `Status::kOk` as the first argument and a non-null value as the second tuple argument. Function calls that fail, would have a null value as the second tuple argument, We could go further, and then in Java 8 use an `Optional<T>` as the second argument.\r\n\r\n4. Remove exceptions entirely (Approach B) - Change the functions in RocksJava that can throw a RocksDBException to instead return an `Either<Status, T>`. All successful function calls will return an `Either.Right<T>`, whilst function calls that fail would return an `Either.Left<Status>`. Working with a disjunction type (*Either<L, R>*) would be easier in Java 8."},"comment":{"url":"https://api.github.com/repos/facebook/rocksdb/issues/comments/237006601","html_url":"https://github.com/facebook/rocksdb/issues/1250#issuecomment-237006601","issue_url":"https://api.github.com/repos/facebook/rocksdb/issues/1250","id":237006601,"user":{"login":"dhruba","id":155266,"avatar_url":"https://avatars.githubusercontent.com/u/155266?v=3","gravatar_id":"","url":"https://api.github.com/users/dhruba","html_url":"https://github.com/dhruba","followers_url":"https://api.github.com/users/dhruba/followers","following_url":"https://api.github.com/users/dhruba/following{/other_user}","gists_url":"https://api.github.com/users/dhruba/gists{/gist_id}","starred_url":"https://api.github.com/users/dhruba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhruba/subscriptions","organizations_url":"https://api.github.com/users/dhruba/orgs","repos_url":"https://api.github.com/users/dhruba/repos","events_url":"https://api.github.com/users/dhruba/events{/privacy}","received_events_url":"https://api.github.com/users/dhruba/received_events","type":"User","site_admin":false},"created_at":"2016-08-02T18:57:37Z","updated_at":"2016-08-02T18:57:37Z","body":"I vote for (1) as well."}}
{"actor":{"display_login":"dhruba"}}