question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Throwing the wrong exception

See original GitHub issue

This line tries to throw the exception of fa. But what if fb was faulted and fa was not?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
louthycommented, Feb 21, 2018

On a related note, what is the meaning / intention between the classes MTask<> and MTaskFirst<>?

https://github.com/louthy/language-ext/issues/339

0reactions
TysonMNcommented, Feb 27, 2018

Actually, most of this is dead code. I used to know this and was just recently reminded of how this works.

The documentation for Task.WhenAll says

If any of the supplied tasks completes in a faulted state, the returned task will also complete in a TaskStatus.Faulted state, where its exceptions will contain the aggregation of the set of unwrapped exceptions from each of the supplied tasks.

Furthermore, when awaiting a failed Task, an exception is thrown. Therefore, most of the method is just dead code. It can be simplified to just

public async Task<A> Apply(Func<A, A, A> f, Task<A> fa, Task<A> fb) 
{
    await Task.WhenAll(fa, fb);
    return f(fa.Result, fb.Result);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong exception being thrown - java
1 Answer 1 ... The exception is thrown, but then you have a catch block that doesn't do anything and allows the execution...
Read more >
How to Throw Exceptions in Java
Throwing an exception is as simple as using the "throw" statement. You then specify the Exception object you wish to throw. Every Exception...
Read more >
Creating and Throwing Exceptions
Learn about creating and throwing exceptions. Exceptions are used to indicate that an error has occurred while running a program.
Read more >
How to Throw Exceptions (The Java™ Tutorials > Essential ...
Most programs you write will throw and catch Exception s as opposed to Error s. The Java platform defines the many descendants of...
Read more >
7 Common Mistakes You Should Avoid When Handling ...
Mistake 1: Specify a java. · Mistake 2: Catch unspecific exceptions · Mistake 3: Log and throw an Exception · Mistake 4: Use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found