{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/3786","repository_url":"https://api.github.com/repos/ReactiveX/RxJava","labels_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/3786/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/3786/comments","events_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/3786/events","html_url":"https://github.com/ReactiveX/RxJava/issues/3786","id":142299638,"number":3786,"title":"timeout eats exceptions","user":{"login":"AAverin","id":1481332,"avatar_url":"https://avatars.githubusercontent.com/u/1481332?v=3","gravatar_id":"","url":"https://api.github.com/users/AAverin","html_url":"https://github.com/AAverin","followers_url":"https://api.github.com/users/AAverin/followers","following_url":"https://api.github.com/users/AAverin/following{/other_user}","gists_url":"https://api.github.com/users/AAverin/gists{/gist_id}","starred_url":"https://api.github.com/users/AAverin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AAverin/subscriptions","organizations_url":"https://api.github.com/users/AAverin/orgs","repos_url":"https://api.github.com/users/AAverin/repos","events_url":"https://api.github.com/users/AAverin/events{/privacy}","received_events_url":"https://api.github.com/users/AAverin/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ReactiveX/RxJava/labels/Question","name":"Question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-03-21T09:51:29Z","updated_at":"2016-03-21T12:20:10Z","closed_at":null,"body":"If I have a custom Observable that published some exceptions in onError, chaining such observable with timeout(time, units, MyCustomTimeoutException()) hides exceptions that are sent by custom observable.\r\n\r\nSome example.\r\nSecurityException and IllegalArgumentException never reach my subscriber.\r\n```\r\nfun getLocation(): Observable<Location> {\r\n        return requestSingleLocation()\r\n                .subscribeOn(schedulers.loopedIo)\r\n                .timeout(LOCATION_REQUEST_TIMEOUT,\r\n                         TimeUnit.SECONDS,\r\n                         Observable.error(NetworkLocationTimeoutException()))\r\n                .first()\r\n    }\r\n\r\n    private fun requestSingleLocation(): Observable<Location> {\r\n        return Observable.create<Location> { subscriber ->\r\n\r\n            try {\r\n                val knownLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)\r\n                knownLocation?.apply {\r\n                    subscriber.onNext(this)\r\n                }\r\n\r\n                locationManager.requestSingleUpdate(LocationManager.NETWORK_PROVIDER, LocationChangedListener {\r\n                    subscriber.onNext(it)\r\n                    subscriber.onCompleted()\r\n                }, null)\r\n\r\n            } catch (securityException: SecurityException) {\r\n                subscriber.onError(securityException)\r\n            } catch (illegalArgumentException: IllegalArgumentException) {\r\n                subscriber.onError(illegalArgumentException)\r\n            }\r\n        }\r\n    }\r\n\r\n```\r\n\r\nFollowing test fails:\r\n```\r\n@Test\r\n    fun getLocationProcessesSecurityException() {\r\n        // given\r\n\r\n        val securityException = SecurityException()\r\n        given(locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)).willReturn(location)\r\n        given(locationManager.requestSingleUpdate(BDDMockito.anyString(), any(), any())).willThrow(securityException)\r\n        val testSubscriber = TestSubscriber<Location>()\r\n\r\n        // when\r\n        classToTest.getLocation().subscribe(testSubscriber)\r\n\r\n        // then\r\n        testSubscriber.assertError(securityException)\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/ReactiveX/RxJava/issues/comments/199248455","html_url":"https://github.com/ReactiveX/RxJava/issues/3786#issuecomment-199248455","issue_url":"https://api.github.com/repos/ReactiveX/RxJava/issues/3786","id":199248455,"user":{"login":"AAverin","id":1481332,"avatar_url":"https://avatars.githubusercontent.com/u/1481332?v=3","gravatar_id":"","url":"https://api.github.com/users/AAverin","html_url":"https://github.com/AAverin","followers_url":"https://api.github.com/users/AAverin/followers","following_url":"https://api.github.com/users/AAverin/following{/other_user}","gists_url":"https://api.github.com/users/AAverin/gists{/gist_id}","starred_url":"https://api.github.com/users/AAverin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AAverin/subscriptions","organizations_url":"https://api.github.com/users/AAverin/orgs","repos_url":"https://api.github.com/users/AAverin/repos","events_url":"https://api.github.com/users/AAverin/events{/privacy}","received_events_url":"https://api.github.com/users/AAverin/received_events","type":"User","site_admin":false},"created_at":"2016-03-21T12:20:10Z","updated_at":"2016-03-21T12:20:10Z","body":"Sorry, it's in Kotlin though"}}