Questions tagged [catch-block]

The `catch-block` in a program is used to handle an `exception` thrown by a block of code.

144 questions
0
votes
3 answers

How to Avoid Throwing An Error When SQL Select Returns Nothing

I read somewhere that one should never use error conditions as normal program flow. Makes excellent sense to me... But C# application sitting on top of a MySQL db. I need to parse a string value into two parts, an ID, and a value. (The original data…
EoRaptor013
  • 1,735
  • 4
  • 18
  • 31
0
votes
1 answer

Is there a way to separate out information provided in cause for exceptions?

When I am printing the cause of TimeoutException caused by NoSuchElementException as in : catch (TimeoutException tox) { tox.printStackTrace(); printWarn("Cause for failure => " + tox.getCause()); } The output to what I get…
Naman
  • 27,789
  • 26
  • 218
  • 353
0
votes
0 answers

TCL catch ignores error

proc handler { args } { if { [catch {eval $args} errorMessage] } { _report_error "$errorMessage" } } args is script which has call from another TCL file proc is_threshold_percent {thresholdValue } { #some code here if { […
0
votes
4 answers

.Net: What is your confident approach in "Catch" section of try-catch block, When developing CRUD operations?

I was wondering if there would be any confident approach for use in catch section of try-catch block when developing CRUD operations(specially when you use a Database as your data source) in .Net? well, what's your opinion about below lines? public…
odiseh
  • 25,407
  • 33
  • 108
  • 151
0
votes
1 answer

Using continue statement in catch block

I have a foreach loop that is looping through an entity framework result. Each result is being passed through a function. So to catch any errors I have a try/catch block setup. Something like this: foreach (var resetReq in query) { try { …
ITninja04
  • 53
  • 2
  • 5
0
votes
1 answer

Automaticall replacing single catch clauses with duplicate catch clauses

Does anyone know whether there is a tool or something similar to replace single catch clauses with duplicate code within it in java with multiple catch clauses to remove duplicate code? Context is an upgrade vom java jdk6 to 7. Thanks and cheers,…
Stefan
  • 1,590
  • 3
  • 18
  • 33
0
votes
2 answers

java catch block is causing multiple outputs

I wrote a program to accept input from a text file, and display the words from the file in ascending order with no duplicates. The output is correct if there is no exception thrown. If the exception is thrown, the user is asked for valid input and…
snaper
  • 5
  • 3
0
votes
0 answers

Catching an error from a 3rd Party function in Javascript

I'm using an ID3 tag reader library https://github.com/43081j/id3 & the example function to call is in this format... id3(this.files[0], function(err, tags) { console.log(err, tags); }); It works great for most files but from time to time there…
Chris
  • 1,054
  • 2
  • 12
  • 24
0
votes
1 answer

SQLite gives Exception

I am struggeling with adding a list of items into a database, I want to keep adding a person's data as I add more of the items. Here is my code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using…
user2980509
  • 132
  • 1
  • 3
  • 12
0
votes
1 answer

Haskell Sqlite3 - Catching exceptions

I would like to know how I can catch an exception if raised by the following piece of code query_3 <- quickQuery' conn_1 "SELECT MAX(high) \ FROM historicalData " [] mapM_ (putStrLn…
Prasadika
  • 897
  • 2
  • 20
  • 36
0
votes
2 answers

Throwing and catching exceptions #2

I've a console application that zips files and then send them via email. It does that every hour. I wanted to know what kind of exceptions should I handle ? Let say if there's no network available when the process starts. What exception will I get…
user2901683
  • 175
  • 1
  • 1
  • 12
0
votes
2 answers

If possible to cotinue a For Each loop after an error jump in VB.NET?

I have a BackGroundWorker with a For Each loop that is inside of a Try Catch and I need to detect the error and continue the For Each loop whit the next item. Actually I have a list of data to send to a server trough UDP and wait for an ACK, but if…
E_Blue
  • 1,021
  • 1
  • 20
  • 45
0
votes
1 answer

How to catch the error on screen into variable in TCL using catch

To grep the error on the screen though catch eg puts $c #error on terminal : can't read "c": no such variable catch {puts $c} err puts $err # value of err 1 Is there any way to catch actual error message in TCL apart from signal in…
made_in_india
  • 2,109
  • 5
  • 40
  • 63
0
votes
1 answer

does not work with JSTL 1.2

I'm implementing a simple JSP page using JSTL 1.2 (Apache Taglibs). The page does the following: The HTML input element looks like…
Ilio Catallo
  • 3,152
  • 2
  • 22
  • 40
-1
votes
1 answer

Why is `.then()` processed when fetch fails?

Consider the following code where I tried to shield fetch against any unsuccessful connections (I call them non "200-ish" in the comments) and provide a function that will make use of its successful results: const callApi = () => { return…
WoJ
  • 27,165
  • 48
  • 180
  • 345
1 2 3
9
10