Skip to content

Releases: tvandinther/Fallible

0.2.4

23 Mar 06:48
c3638d6
Compare
Choose a tag to compare

What's Changed

  • Add some logical chaining methods for fallible types. by @tvandinther in #8

Full Changelog: 0.2.3...0.2.4

0.2.3

23 Mar 03:48
d6b0454
Compare
Choose a tag to compare

What's Changed

  • Add methods for conversion of Fallible value to covariant and contravariant types by @tvandinther in #7

Full Changelog: 0.2.2...0.2.3

0.2.2

23 Mar 03:47
Compare
Choose a tag to compare

0.2.1

23 Mar 03:46
1ee1cb6
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.2.0...0.2.1

0.2.0

18 Mar 04:55
Compare
Choose a tag to compare

Fallible namespace changed to FallibleTypes to prevent a clash of the namespace name and static class name. This change should improve the experience with IntelliSense and imports.

0.1.5

18 Mar 04:29
f5bc9e4
Compare
Choose a tag to compare

Add implicit unwrapping and remove tuple conversion

Conversion for implicit unwrapping is added to facilitate usage in wrapper functions. The tuple conversion is also removed to better enforce the two possible states (Failed, Not Failed).

0.1.4

16 Mar 22:27
bb89448
Compare
Choose a tag to compare

Chaining error messages

When dealing with an Error object, often you may want to pass the error up the call stack. As it is passed up the call stack, the level of abstraction is increased which can give increasing context to the error message. To facilitate this best practice, the Error object allows string concatenation with itself.

Fallible<User> GetUserFromDB(UserId id)
{
    if (!databaseIsConnected) return new Error("Database is not connected");
    ...
}

Fallible<User> FindUserById(UserId id)
{
    var (user, error) = GetUserFromDB(id);
    if (error) return "Could not find user: " + error;
    
    return user;
}

var (user, error) = FindUserById(id);
if (error)
{
    Console.WriteLine(error); // "Could not find user: Database is not connected"
}

Messages can also be appended by putting the string on the right hand side of the + operator.

return error + ": Could not find user";

Error message formatting

To ensure that error messages are not accidentally overwritten, directly setting the Error.Message property is not possible. If appending or prepending from the error message is not suitable, you can use the Error.Format method to format the message more comprehensively. This method functions exactly like the string.Format method and uses that in its implementation.

return error.Format("Could not find user: {0}: Aborting...", error.Message);

0.1.3

13 Mar 23:24
242feee
Compare
Choose a tag to compare

Fallible now includes a Void type that can be used to return void from a method. It does not have an accessible constructor and can only be created by using the Fallible.Return property.

public Fallible<Void> DoSomething()
{
    // Do something
    if (somethingFailed) return new Error("Something went wrong");
    
    return Fallible.Return;
}

0.1.2

08 Mar 21:59
Compare
Choose a tag to compare
  • Error class now implements its own ToString method.
  • New Fallible<T> Fallible.Try(Func<T> closure) method to catch exceptions and wrap them into a Fallible<T> object.

0.1.1

08 Mar 19:59
Compare
Choose a tag to compare
Update README

Include documentation