How do I catch generic fault exceptions in Fitnesse? - fitnesse

Previously within my Fitnesse fixture I was specifying an expected WCF exception using:
exception[FaultException]
Since then I have converted the WCF service to return a strongly typed FaultContract. I am now getting the following failure message:
exception[FaultException`1: "A file with the name DMS Documents/testFileWord.doc already exists. It was last modified by SHAREPOINT\system on 09 Mar 2010 15:36:14 -0000."]
This is not unexpected but how do I check for strongly typed fault exceptions? Please note I cannot include the fault message as part of the check as it contains a date which changes (I check this separately).

Try specifying the exception name that's being generated: exception[FaultException`1]
I've added an issue to use the full generic type name if the exception type is generic. http://github.com/jediwhale/fitsharp/issues/issue/44

Related

Errors after closing and opening project in visual studio

Almost always when I close a project in Visual Studio, it almost alwyas have these types of errors (written down below) when I open the project again, even if it didn`t have any errors when I closed the program. Anyone who knows why this happens and how I could fix it?
Error CS0101 The namespace 'uppdrag_2.cs' already contains a definition for 'Program'
Error CS0101 The namespace 'uppdrag_2.cs' already contains a definition for 'SecondClass'
Error CS0111 Type 'Program' already defines a member called 'Main' with the same parameter types
Error CS0111 Type 'Program' already defines a member called 'Newcustomer' with the same parameter types
Error CS0121 The call is ambiguous between the following methods or properties: 'Program.Newcustomer()' and 'Program.Newcustomer()'
Thank you in advance!
//Johanna

Unable to retrieve metadata for 'MVCMusicStore.Models.Album

In section 5 of the ASP>NET MVC Music Store example, "Creating the StoreManagerController," when I click "Add" I get the error,
There was an error running the selected code generator:
'Unable to retrieve metadata for 'MVCMusicStore.Models.Album.'
The popular solution is to comment out the connection string in Web.config. This did not work for me. After trying many things I decided to add the code manually, by taking it from the completed code that's included with the example. When I do that I receive the error,
Compiler Error Message: CS0234: The type or namespace name 'Album' does not exist in the namespace 'MvcMusicStore.Models' (are you missing an assembly reference?)
and on line 31 I see the error,
public class _Page_Views_StoreManager_Index_cshtml : System.Web.Mvc.WebViewPage<IEnumerable<MvcMusicStore.Models.Album>>
Album is defined in the models folder. I have used webform development many times and am trying to add MVC to my repertoire. It seems to me "Album' is not registered, but I don't even know if that's appropriate lingo for MVC. What's the problem? I'm running this example in Visual Studio 2017.
The problem with line 31 is my project is named "MVCMusicStore". In the completed code I imported it's "MvcMusicStore". So it's looking at the wrong thing for the 'Album'namespace. Still don't know what causes the first error.
After correcting the namespace in the sample file, that error goes away and the new error is on the line;
#foreach (var item in Model{
the error is "System.NullReferenceException 'Object reference not set to an instance of an object.'

Startup.cs - The path in 'value' must start with '/'

I have created a new .NET Core MVC application in Visual Studio 2017 and enabled multi-tenant authentication.
I've completed the configuration (ClientId, Authority, etc) but when I debug the application there is an exception in the Startup.cs, specifically the app.useOpenIdConnectAuthentication method.
The exception given is
System.ArgumentException: The path in 'value' must start with '/'.
I'm a bit of a novice when it comes to C# and .NET Core, so I'm not sure whether I'm missing something obvious. The main sticking point is what the debugger is referring to with the parameter 'value' as I can't see any mention of it in the code. There are no changes beyond the default template generated by visual studio, other than adding the configuration items to the appsettings.json.
As there is no code in the question, so I will try to make a general answer as possible.
This exception appears when you use this overload PathString.FromUriComponent(string) and the string does not start with the / character
so,for example, the following code will throw an exception :
PathString.FromUriComponent("controllerName/actionName"); // throw exception
and to fix the previous exception you can write it like this
PathString.FromUriComponent("/controllerName/actionName"); // working, but as relative path
and of course, this will be a relative path.
In case you wanted to use an absolute path, (and not start your string with /), then you must use another overload of this method which takes Uri object as a parameter instead of string
here is an example
// use an absolute path
PathString.FromUriComponent(new Uri("https://localhost:8000/controller/action/"))
I also get the same exception, but with another method UseExceptionHandler:
The error was:
ArgumentException: The path in 'value' must start with '/'. Nombre del parĂ¡metro: value Microsoft.AspNetCore.Http.PathString..ctor(string value) Microsoft.AspNetCore.Builder.ExceptionHandlerExtensions.UseExceptionHandler(IApplicationBuilder app, string errorHandlingPath)
Fixed by replacing
app.UseExceptionHandler("Home/Error");
with
app.UseExceptionHandler("/Home/Error");
notice the addition of the / char at the beginning of the string.

Error: An error occurred while skipping data rows

I am getting these errors in flat file connection manager.
Error: [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Flat File Source returned error code 0xC0202091. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.
I am reletively new to ssis and I am finding it quite hard to figure out the issue. Please let me know your views.
On your flat file connection properties - Look for the property "AlwaysCheckForRowDelimeters" - SET it to FALSE.
Hope that helps.
"An error occurred while skipping data rows" - I had this error in a package and found the problem was reading files inside a for loop. More files matched the criteria than intended, so a file with an invalid schema was also matched.
More generally I think this is related to either the file not matching the connection definition, I have also seen people online saying it is related to the flat file using a text qualifier (i.e. " in a csv) but having no closing quote.
I had this error today, and my package was looking for more files than existed based on the conditions of the for each loop. The text qualifier wasn't the issue causing this particular error.
near the Start button press drop-down menu arrow
choose package_name Debug Properties
than under Configuration Properties open Debugging
than under Debug Options choose Run64BitRuntime and turn it to False

class EVariantTypeCastError with message 'Could not convert variant of type (String) into type (Double)

Using Delphi and FastReport I get this error message while debugging inside Delphi immediately after this line:
<FastReport_Component>.ShowReport(true);
Then this error appear:
Project myapp.exe raised exception class EVariantTypeCastError with message 'Could not convert variant of type
(String) into type (Double)'.
It appears twice before displaying the report. but if I run myapp without debugging no error message appear.
How I can find which memo cause this error ? the report has so many memos. some has also expressions inside using IIF and the error message does not display any more info.
This is just the debugger. It's probably just getting an expected error (one handled by a try..except in the FR code) and properly dealing with it, but the debugger has no way of knowing that and tells you the exception happened. (It's a common issue when working with Indy, which raises exceptions as part of normal program flow.)
There are three ways to deal with this situation when debugging:
Just hit Continue on the exception dialog when it appears. (You can tell it's a debugger exception because you get the Break or Continue option, and because it only happens when debugging.)
You can disable a specific exception class (or all exceptions) when debugging, using the Tools->Options->Debugger Options. In this case, you can add EVariantTypeCastError to the list of exceptions to ignore.
(My preferred method) Use the Advanced Breakpoint Properties dialog to skip the debugger's exception handling around the specific line of code you know will raise the exception you want to ignore.
Set a breakpoint on the line immediately before the problem code line.
Right-click the breakpoint on the line before, and choose Breakpoint Properties from the context menu.
Click the Advanced button on the Breakpoint Properties dialog, and in the Actions groupbox, uncheck Break and check Ignore subsequent exceptions.
Repeat the previous steps on the line after the problem code, except check Break and uncheck Ignore subsequent exceptions on this second breakpoint.
Run your code as usual. The debugger will skip it's exception handling on the code between the two breakpoints.
The advantage of option #3 is that it ignores all exception handling, but only on the code block between the two breakpoints, so you still get exceptions in all other areas of your code that may be valid exceptions in the debugger.
I got this exact same error but not with FastReport. I'll leave the context of my error, as it may help someone else. I got this error on:
RESTRequest.Execute();
I was using the TClientDataSet with TRESTResponseDataSetAdapter so that after a request to my web service the adapter would load a data set with the JSON string returned by the web service. This data set was being used to automatically check/uncheck checkboxes and load textedits and comboboxes. Since TJSONObject does not parse booleans correctly in json, I changed some checkboxes to check/uncheck based on an integer value instead of a boolean. I was then changing my webservice so that it looks for boolean columns in the datatable to an integer value 1 or 0. For some reason (my fault entirely), I was outputting a json with "" in that field instead of the integer ("1" or "0"). And this yielded that exact error. After correcting this, the error disappeared.
I had a similar issue in FastReport. In my case, it was a wrong Format applied to a MemoView. I could find the name of the offending component this way:
Use Break to stop the execution
In the Call Stack panel, find the latest call from a fastreport class (in my case: frxClass.TfrxCustomMemoView.FormatData(...) and double click it.
if you don't have the source code od Fast Report, a dialog appears - just hit Cancel
in Local Variables panel, you will probably see name of the offending component / value / format.

Resources