Questions tagged as 'try-catch'

1
answer

Creating a custom Exception from PDOException [closed]

Hello. I need to implement a custom Exception that extends from PDOException and thereby create some methods that return standard messages. So far I have only found unclear examples. Does anyone have a simple example?     
asked by 26.10.2015 / 18:01
1
answer

Problem with catch in MySQL connection c #

Hello, I'm a beginner in programming and I'm having trouble connecting MySQL in C #, where the code does not check and goes into the catch action. Here is the code: conexaoDataSet = new DataSet(); conexao = new MySqlConnection("SER...
asked by 25.04.2015 / 17:30
1
answer

Java - Swing - Timer with TimeUnit.sleep

I'm using Swing in NetBeans, creating a simple math game (I find it more viable than a calculator) whose goal is to add the random numbers of the buttons until it equals a number between 1 and 10000, which would be shown randomly. I used for...
asked by 22.03.2016 / 20:46
1
answer

What is the best way to do the verification? (Try-catch, multiples if, ...?)

I'm reading thousands of XML files with python. The problem is, there is not always the field in every file. resumo_cv = root.find("DADOS-GERAIS").find("RESUMO-CV").get("TEXTO-RESUMO-CV-RH") resumo_cv_ingles = root.find("DADOS-GERAIS")...
asked by 14.12.2018 / 15:14
1
answer

Loop Infinite in exception handling

I'm trying to make a try to ask for the option number for the user, however I want to do this until he type an integer, I made a try / catch, but when he squeezes it and digit a string he keeps sending a error message several times...
asked by 03.10.2018 / 04:49
1
answer

Try-except, IndexError, Alternatives to solve the error

I have a college job to do, in a way I finished it, but with some gambiarras that I wanted to straighten out and leave the code less confusing and etc. How the program works: Basically it creates a 600x400 screen with a% w of% number of ba...
asked by 23.06.2018 / 05:55
4
answers

How do I skip the "finally" block in C # when the exception is raised?

If the exception is generated, I want to know if there is a way to "skip" the execution of block finally . If there is no exception, finally executes normally. With goto did not work. Code: using System; using System.Col...
asked by 25.06.2017 / 00:54
2
answers

How to generate error in logerro.txt file?

I'm trying to generate errors in the logerro.txt file, but I do not know how to do it. I used the syntax error function but: try{ }else(PDOException $e){ echo'Sistema indisponível'; LogErros($e); I used the above function and gave...
asked by 06.11.2014 / 05:54
1
answer

Difference between Error - Exception - Throwable within catch () [duplicate]

Always when I tried catch I used (Exception e) but a few days ago I came across an exception that did not fit into catch (Exception e) so I discovered that it is not really an exception but an error. Soon I started to swea...
asked by 28.12.2018 / 04:52
1
answer

Handling error connecting to MySQL with PDO

I would like to handle the error that occurs if the MySQL server is not running, I want only one message to appear so I made the following code: function mensagemErro () { throw new \Exception("Error connecting to database"); } function con...
asked by 03.01.2019 / 16:10