reading a file into arraylist then print out - arraylist

enter image description here
I have to write a program that need to read a file into an array list then print it out by JOptionPane. however, when I used Try/Catch statement. the Catch statement had the error that I cannot fix

I found that you have not added System.out.print(ioe) in your Catch (IOException ioe) block. Kindly add it and it will resolve the issue.

Related

exception handling in executable

I'm actually writing a programm to analyze excel data and creating an output file with the analyzed data. For reading the input files I use pandas wrapping a try/except block around to catch IOErrors if any of the input files is opened in the background, otherwise the program crashes. My program has to be converted to an exe. that other people can use it.
Now coming to the problem, if I start the program from the PyCharm IDE the exception handling works fine. But if I start the program as an exe. it always throws the exception even if the input files are closed.
Below my code, just a normal exception handling.
try:
dataset = pd.read_excel(path_cmd_data, engine='openpyxl')
pattern = pd.read_excel(path_cmd_regex, sheet_name='RegexTCM', engine='openpyxl')
production_dates = pd.read_excel(path_cmd_prod_dates, engine='openpyxl')
except IOError:
self.label3.setText('Reading Input Data failed!')
return
Thanks for your help, I'm a bit lost with this problem.

How do I find out what errors a tcl command can generate?

At the tcl try manpage, it has the following example:
try {
set f [open /some/file/name w]
} trap {POSIX EISDIR} {} {
puts "failed to open /some/file/name: it's a directory"
} trap {POSIX ENOENT} {} {
puts "failed to open /some/file/name: it doesn't exist"
}
That's great, it works, but how would I have found out that {POSIX ENOENT} is a possible trap pattern for open? The open manpage doesn't mention it. For a given arbitrary command in tcl, how do I find out what the possible errors are?
try {} trap {} is used when there is a specific error that needs to be trapped.
For a more general trap, use try {} on error {}.
try {
set fh [open myfile.txt w]
} on error {err res} {
puts "Error on open: $res"
}
There is also the catch command:
if { [catch {set fh [open myfile.txt w]}] } {
puts "error on open."
}
References: try catch
The various POSIX errors come from the OS, and you need to take a guess at the system call and look them up. For example, it's not a great reach to guess that the open command maps to the open() system call, and so it has the errors documented there. Some are vastly unlikely with Tcl (e.g., those relating to passing a bad buffer in, which is POSIX EFAULT) but we don't guarantee that the OS won't return them because the OS simply doesn't give that guarantee to us.
We ought to document the most likely ones from commands that touch the operating system, but at a high level:
the POSIX class ones are from the OS (e.g., reading a non-existent file is POSIX ENOENT), and
the TCL class ones are from Tcl's own internal code (e.g., from passing the wrong number of arguments to open, which gives you TCL WRONGARGS, or asking for too large a memory allocation, which gives you TCL MEMORY if Tcl manages to recover).
We're unlikely to exhaustively document all the possibilities (especially in the TCL class) since many are unlikely in correct code.

How to get genesis block value at new bitcoin source?

So I am working bitcoin source 0.15.1
chainparams.cpp script,
Line 120~130,
Trying to find new genesis block's value when starting new.
So I googled many articles, forum, but not yet find working solution.
Unlike v0.8, there Debug.Log file itself seems does not generated even after write printf at source.
Why and how to get to know my genesis block value?
Thanks.
chainparams.cpp contains a line of code that checks whether the chain’s genesis block is equal to a specified hash.
You can see an example for the line here:
hashGenesisBlock = genesis.GetHash();
assert(hashGenesisBlock == uint256("9915158279673d101912be80f25c20627f1dd8bf5231e7c46bfec5ed19737f44"));
To print it the hash of the genesis block, you can use
printf("genesis.GetHash = %s\n", genesis.GetHash().ToString().c_str());
Which prints the genesis block in terminal or debug.log
reference : here

How to determine when AviSynth has an error message without seeing the video output

Is is there a programmatic way to test for errors in Avisynth scripts before seeing the black and red Error message in the output.
We are currently assembling Avisynth script files as a part of an automated encoding routine. When something goes wrong with Avisynth or the source file, Avisynth renders a big black and red error message. Our encoder sees this as a normal video file and keeps on encoding without raising an error.
What is the best way to check for these errors without actually being seeing the output from the video file.
AviSynth has support for try-catch: http://avisynth.org/mediawiki/Control_structures#The_try..catch_statement
I'm not sure how you would signal an error to your encoder from there. As far as I know you must return a clip from the script, and a return statement inside a try/catch block does not return from the entire script anways: http://avisynth.org/mediawiki/The_full_AviSynth_grammar#Closing_Remarks
You can however log error messages to text files, so I've seen people doing this to test an AVS script for error before running it:
script = "file_to_test.avs"
try {
Import(script)
} catch (err) {
WriteFileStart(BlankClip(), "C:\logfile.txt", script, """ ": " """, err, append=true)
}

Getting debug output in SQL Server Management Studio

I'm generating a large script to do a bunch of inserts and updates. When I run it I get some errors, but the error messages don't let me pinpoint the problem - the line numbers are since the last "GO", so I can't find the right line.
I'd like to add calls to my script to a function in T-SQL that will just write to the results window, so I'd have a better idea where the error occurs.
You can simply use PRINT in the pleces that you suspect can cause problems
e.g.
print 'Step 1'
insert into tableA -- some code here
...
print 'Step 2'
etc
You can also wrap your code into block of TRY CATCH statements and throw custom errors or print error messages if something goes wrong
PRINT statements as suggested by #kristof would do what you want.
However you could run SQL Profiler side-by-side when you execute the script, catching all classes in the Errors and Warnings section and all SQL:StmtStarting events -- this would mean you wouldn't have to edit your script.