Making the Intellij debugger show me where an exception was thrown in my own code - intellij-idea

Is there a way to make the Intellij debugger show me where an exception was thrown in my own code? For example, I am currently trying to use the function parseInt of the Integer class to convert a string into an int.
public static int inputAccountNumber(){
Scanner scan = new Scanner(System.in);
System.out.print("Insert account number: ");
return Integer.parseInt(scan.nextLine());
}
In this case, If I just press enter when the input comes up, then an exception is thrown in the Integer class itself (and the debugger stops to show me the exception). However, I don't really care where in the Integer class this exception was thrown, I only want to the debugger to tell me where in my own code this problem occured.
I tried looking in the settings for breakpoints (which is where I enabled the option for the debugger to stop at exceptions), but it doesn't look like it has an option that fixes my problem.
P.S.: I'm on Intellij IDEA 2022.3.1 (Community Edition).

Related

My.settings\ settings.settings keep getting a bad connection with the IDE (Visual studio 2019 community)

I was working on a project that uses my.settings to save some data, but then I made a backup of the project and Factory reset my computer due to low space. I installed Visual studio like normally but now I have problems with my IDE. I continued to work on the previous project but now when I add new settings in My.settings in the designer I get an error stating(The file might be corrupt or contain invalid XML) but then continues to save the new data to the File?? but when I use My.Setttings in my program I get a huge error and the program continues to compile and work except none of the My.settings code i have in the project work dont work??
I got the problems As soon as the new IDE was installed on my Freshly Reset Computer and the error Always appears when I enter new My.settings values or Run the Program.
The Errors I get:
When I enter new Settings:
An error occurred while saving values to the app.config file. The file
might be corrupted or contain invalid XML.
When I run the Code/program:
System.Configuration.ConfigurationErrorsException: Configuration
system failed to initialize
—> System.Configuration.ConfigurationErrorsException: Unrecognized
configuration section system.diagnostics. (D:! Random Work in
progress\Game Save Duplicator\Game Save
Duplicator\bin\Debug\netcoreapp3.1\Game Save Duplicator.dll.config
line 8)
at
System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean
ignoreLocal)
at
System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors
schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String
configKey)
— End of inner exception stack trace —
at System.Configuration.ConfigurationManager.PrepareConfigSystem()
at System.Configuration.ConfigurationManager.RefreshSection(String
sectionName)
at System.Configuration.ClientSettingsStore.ReadSettings(String
sectionName, Boolean isUserScoped)
at
System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext
context, SettingsPropertyCollection properties)
at
System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider
provider)
at System.Configuration.SettingsBase.GetPropertyValueByName(String
propertyName)
at System.Configuration.SettingsBase.get_Item(String propertyName)
at
System.Configuration.ApplicationSettingsBase.GetPropertyValue(String
propertyName)
at System.Configuration.ApplicationSettingsBase.get_Item(String
propertyName)
at Game_Save_Duplicator.My.MySettings.get_DesFol() in D:! Random Work
in progress\Game Save Duplicator\Game Save Duplicator\My
Project\Settings.Designer.vb:line 62
at Game_Save_Duplicator.Form1.Form1_Load(Object sender, EventArgs e)
in D:! Random Work in progress\Game Save Duplicator\Game Save
Duplicator\Form1.vb:line 12
How did i try to resolve this bug?:
I uninstalled the IDE and installed it hoping the dumb errors would go away as I think it has something to do with the IDE because....previous working programs that use my.settings also dont work now?
I reset my computer a second time and installed Visual studio for a third time but this bug still exists.

Why does Visual Studio throw an exception when declaring a list of string array

I don't know guys but Visual Studio just start acting crazy , my code was working fine I just added one column to a listview added a line of code tested some things and then reloaded the project without saving it (just to revert the project to its last state) but now when I load the project and start debugging I get an exception when declaring a variable on a form i didn't even load it my project structure is like this :
|<Settings
Splash screen --> Main Form --><Equalizer
|<Tags
The above meant that my project starts with splash screen and after 3 seconds it loads the main form which acts like a home for the app and then from there you can do regular media player stuff and also call three other forms {settings, equalizer and tags}, so when I start the project the splash screen load normally, the second it tries to call main form it throws an exception on this piece of code
Dim extendedinfoarray As New List(Of String())
Here is the exception info :
System.ArgumentOutOfRangeException occurred
HResult=-2146233086
Message=DisplayIndex value is out of bounds. Value must be greater than or equal to 0 and less than or equal to number of columns minus 1.
Parameter name: DisplayIndex
ParamName=DisplayIndex
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.ColumnHeader.set_DisplayIndex(Int32 value)
at MrAudio.TaggingForm.InitializeComponent() in D:\Visual Studio Project Files\MediaPlayerFullFormProj\MediaPlayerFullFormProj\TaggingForm.Designer.vb:line 1668
at MrAudio.TaggingForm..ctor() in D:\Visual Studio Project Files\MediaPlayerFullFormProj\MediaPlayerFullFormProj\TaggingForm.vb:line 8
I'm using .NET 4.6.1
So what can be causing Visual Studio to start throw a random exception like this, I thought it can't throw an exception when declaring a variable. Can it?
Thanks in advance,
PS: this is my first question on StackOverflow if I didn't provide enough details just ask.
The problem is related to the ListView itself after removing a column, adding another one and arranging it will cause this problem
Quick fix :
Edit form designer file search for the ListView settings section change the column arrange to the correct one , or remove all columns, compile and start, then add those columns again and that should fix the problem.

Debug.Assert() isn't thrown

I have the following code:
As you can see from the quickview tooltip, nNewCell.Style is Nothing.
Despite of that, the lines
Debug.Assert(nNewCell.Style IsNot Nothing)
Debug.Assert(nNewCell.Style.GUID <> "")
aren't thrown.
The IDE doesn't raise an exception or stop there, the IDE simply ignores these lines.
My project settings are Debug x86.
What might be causing this problem?
Project Properties ➤ Compile ➤ Advanced Compile Options
You will see a checkbox for Define DEBUG constant. This must be checked for Debug functions to work. If it's not, they will be ignored and not compiled into your assembly.
This definitely seems like you are missing the DEBUG constant because your code should be throwing a NullReferenceException due to the line Debug.Assert(nNewCell.Style.GUID <> "") and your screenshot showing it was Nothing.
One quick note. This issue really simple to cause and I have lost a decent amount of time before tracking down issues related to this. When creating a new configuration, always copy the appropriate type (Debug or Release). Issues like this are usually caused by copying a Release or non-debug config, but then attempting to treat them as Debug.

XCode - Finding errors

I'm relatively new to XCode (4.5) and i've ran into some problems with finding an error.
My project has suddenly started throwing out the following error when I attempt a model segue to open a view where I can add an item to a list - this previously was working.
"...-[TestUnit isEqualToString:]: unrecognised selector sent to
instance 0x89d4250"
I've had a google around using breakpoints and I've added an "All Exceptions Breakpoint" to my breakpoints list but it's made no difference, my console still isn't terribly helpful to me (in my new eyes), I've no idea where in my project this error is...
I've used NSLog to trace out to the console and the error appears to be occuring within prepareForSegue and I've even commented out every occurence of isEqualToString within the project and the error is still thrown...
Would anyone mind giving me some much needed pointers to get to the bottom of this?
Many thanks,
Matt
Goto to Xcode -> breakpoint navigator -> add + -> "add exception Breakpoint" -> run project
once exception occur check where is crashed, Print objects reference,
it have desire value or not?

How to get COMplusExceptionCode from a standard Exception

How do I get the COMplusExceptionCode from a standard Exception that doesn't already have it in the GetMessage? Thank you very much.
try
{
...
}
catch(Exception ex)
{
// How do I get the COMplusExceptionCode from ex?
}
I'm aware that this was asked a long time ago, but for anyone still looking for an answer to this, there are a number of ways of finding the COMException code if Visual Studio hasn't generated a .NET Exception object for you.
You first need to add a break point into your COMException catch statement to catch the exception. Then do one of the following:
The easiest method is to use the debugging controls to step into the catch statement, where Visual Studio should display a warning icon underneath the exception... click on this to view the related .NET exception. If Visual Studio has not generated a related exception, keep reading.
Use Intellisense - put your mouse cursor over the name of the exception in the catch declaration and drill all the way down to the Non-Public members section.
Use the Quick Watch Window to view the exception object and drill down to the Non-Public members section as above.
Type System.Exception._COMPlusExceptionCode into the Immediate Window.
All you will see for methods 2-4 however, is a single code number that you will then have to search the internet to find a meaning for.