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.

"Input string was not in a correct format."

See original GitHub issue

Hi, I have been using your Outcomes for a while and it helps me a lot until today I have a weird error. I have a function return IOutcom<int> as following:

public IOutcome<int> CreateResource(string type, string json, string id)
{
...
IOutcome<IList<ValidationError>> validation = ValidateResource(rType,json);
			
	if (validation.Failure)
	{
		string message = "Resource is invalid: " + JsonConvert.SerializeObject(validation.Value);
				
		return Outcomes.Failure<int>().WithMessage(message);
	}
			
...
}

the “return” line keeps raise an exception “Input string was not in a correct format.”, I have tried WithMessage(“message”), it had the same error, but WithMessage(“1”) has no problem. It looks it trying to cast the string in WithMessage to int, why?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
lbcsycommented, Feb 14, 2018

What if check the paramList first ? At least it won’t cause trouble if my intention is a simple string message.

public SuccessOutcomeBuilder<TValue> WithMessage(string message, params object[] paramList) { if ( paramList !=null && paramList.Length >0) { message = string.Format(message, paramList); } base.Messages.Add(message); return this; }

0reactions
lbcsycommented, Feb 21, 2018

I have created a pull request. This is my first time use Github “pull request”, please let me know if I have done something wrong.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Input string was not in a correct format
The error means that the string you're trying to parse an integer from doesn't actually contain a valid integer.
Read more >
How to resolve "Input string was not in the correct format" ...
An attempt to reload this user information into the screen, produces the "Input not in the correct format" error just because the prepopulated ......
Read more >
Input String Was Not in a Correct Format: Working Solutions
Input string was not in a correct format error occurs when you convert non-numeric data into an int or exceed the limit of...
Read more >
System.FormatException: 'Input string was not in a correct ...
When dealing with a TextBox that should be an int do not allow invalid entries e.g. disallow non in values then use intTryParse...
Read more >
[Solved] C# system.formatexception: 'input string was not in ...
I am getting error c# system.FormatException: 'Input string was not in a correct format.' for the below code. I have tried several threads...
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