Comments (4)
Hope PR #74 gets merged and release soon as we've been suffering from this crash in production.
I think it's more reproducible when dealing with coroutines where sometimes a CancellationException
is thrown due to the CoroutineScope of the current suspend method gets cancelled, and since in the mapError
we're expecting our custom domain exception class it crashes instead due to ClassCastException.
Example:
remoteDataSource.retrieveFromDataSource() // Returns a SuspendableResult<Data, DataSourceException>
.mapError { exception: DataSourceException -> } // Crashes here because a JobCancellationException was thrown but we're expecting a DataSourceException
from result.
This happens in case of Result
as well. It would be better not to handle these exceptions at all. Because ClassCastException
in the least expected moment at runtime is not a good thing, in my opinion.
What do you think @kittinunf ?
from result.
To be honest, I am reluctant to add this functionality. Do you think you can have a top-level exception that every other error conforms too and use that one instead?
from result.
It has been merged quite some time ago! Please report it back whether it solves the problem or not.
from result.
Related Issues (20)
- Seems like there is a lib that does this : Try HOT 3
- Android Studio always tried to import kotlin.Result HOT 3
- Dealing with unexpected exceptions more elegantly HOT 7
- Does not work with kotlin 1.3.20 HOT 1
- Opinion on stdlib `kotlin.Result<T>` in kotlin 1.3 HOT 8
- Can't find coroutines 2.1.0 on jcenter HOT 3
- Error Response Handling HOT 1
- What about adding a label to each validation? HOT 1
- Does this library supports Gson serialization?
- getOrNull HOT 8
- Question: Proper usage of SuspendResult? HOT 1
- Provide functions to unwrap value or error HOT 2
- Why isn't using E extends kotlin.Exception instead of E: kotlin.Exception HOT 2
- Functions should have contracts HOT 2
- Provide an idiomatic way to flatten List<Result> HOT 4
- `.map{}` Not Catching any exception thrown in tranform Function HOT 2
- Enforced nullability on get()'s return type HOT 6
- `flatMapError` should take value type (V) to consideration HOT 2
- Support Javascript Backend
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from result.