Comments (5)
Well, unlike Fuel, I don't think Result should support Java. It aims at the beginning that it was meant to support Kotlin and solely Kotlin.
from result.
I'm not requesting for a lot, just a way to know if it is failed (only possible in try catch of get()
or component2()
) and getting the exception, from Java.
from result.
Fair enough. I haven't used Java for a big while for I wouldn't know exactly what really Java client wants. If you have some proposal and it doesn't alter Result too much, I am happy to accept it.
from result.
I'm not interested in Java support but if this is meant solely to target Kotlin I'm wondering why the errors in Result require Exception as a base class as opposed to Kotlin's Throwable?
from result.
Good point! Thanks for asking. When I designed this Result
class (which was kinda long ago), I considered Throwable
as well. However, I dropped it at the last minute in favor of Exception
.
There is a reason for it though. If I use Throwable
, client could use Error
for a Failure case in Result
which is not semantically what I want. I prefer the Failure case to be an error state which is recoverable, that is mostly like be represented by Exception
as opposed to a non-recoverable (serious) like Error
.
If you could come up with a use case which is likely better to represent as Throwable
, I am happy to discuss.
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
- Result.map {} can cause a ClassCastException if an exception that isn't of the right type is thrown inside it HOT 4
- 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.