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.

How to use nested Result<> functions?

See original GitHub issue

How can I get the Result<> exception (if is there one?)

What I’m trying to do is this:

private Result<string> GetMyString()
{
    ...
}

public Result<string> MyMethod()
{
   var strResult = GetMyString();
   if (!strResult.IsSuccess)
      return new Result<string>(strResult.GetException()); // <-- ???

   // other things that can return a string or an exception
}

Am I missing something?

And if the only correct way is to use just the Match() method, how should I do? because this doesn’t work

public Result<string> MyMethod()
{
   var strResult = GetMyString();
   return strResult.Match<Result<string>(
      x=> 
      {
          if(something)
              return x;
          else
              return new Result<string>(new Exception("error message"));
      },
      ex => new Result<string>(ex)
   );
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
louthycommented, Jan 31, 2023

You’re free to create your own type called Final

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use nested functions in a formula
Use nested functions in a formula · Click the cell in which you want to enter the formula. · To start the formula...
Read more >
Nested Functions - MATLAB & Simulink
Nested functions can use variables that are not explicitly passed as input arguments. · In a parent function, you can create a handle...
Read more >
How nested functions are used in Python?
A. A nested function refers to a function that is defined within another function's body. In programming languages that support this feature ( ......
Read more >
Nested function
Lexically nested function definitions are a form of information hiding and are useful for dividing procedural tasks into subtasks which are only meaningful ......
Read more >
How can I use the result of a nested function?
There are a couple problems here: 1) You aren't actually invoking returnFunction , just referencing the function in your return statement.
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