Questions tagged as 'try-catch'

2
answers

What exceptions should I catch in a try-catch?

I have some questions in try catch regarding which types of exceptions to put. This example would be the best option? try { String folerPath = Environment.getExternalStorageDirectory() + File.separator + "Folder" + File.separator;...
asked by 11.09.2015 / 15:33
2
answers

How to use try and catch with PHP?

I have a question about how to apply try and catch to a method. public function cadastrarUsuarios(parametros){ mysqli_query($this->conexao,"INSERT...."); // Aqui que vem a dúvida try{ if(mysqli_affected_rows($t...
asked by 28.12.2017 / 11:57
1
answer

Try-catch in loop causing error

I have the following code, which tries to click a button after 60 seconds, and if it has not loaded, try again after 60 seconds. while(true) { var timeout = setTimeout(function() { try{ document.querySelector...
asked by 10.12.2018 / 15:03
1
answer

How to use try, catch, finally, and exception in php

I have source where I need to now adapt it to use try , catch , finally and exception and I'm not getting it, this font already has some try´s com catch(PDOException $erro) where I do some validations, bec...
asked by 21.12.2017 / 17:22
2
answers

Is it necessary to put the element type inside the try?

When optimizing my JDBC code I started using a condition inside the try. /** Função PreparedStatement stmt */ public PreparedStatement stmt; /** Funçãoo ResultSet rs */ public ResultSet rs; /** Método LoginDao - construtor */ public Login...
asked by 20.08.2015 / 20:26
1
answer

Get error message in Post HttpClient

I have a WCF Service on a server whose service is also configured as WebInvoke: [WebInvoke( Method = "POST", UriTemplate = "/work", BodyStyle = WebMessageBodyStyle.WrappedResponse, ResponseFormat = WebMessageFor...
asked by 28.06.2017 / 14:22
1
answer

Javascript Runtime Exception

I'm trying to make a dynamic file call where I have a input that gets a name and a file with that name is loaded in the <source> in js, when the person types a file name that does not exist in the folder you would need to dis...
asked by 30.11.2016 / 05:11
2
answers

Skip file when entering some Exception

Good afternoon Below is a method that I use to read certain files in a folder. The problem is this. If the folder has 50 files (or 60, or 70, or 80 ...) and the method is reading a "defective" file (one of the files that fall in Exeception...
asked by 16.01.2017 / 19:56
0
answers

If or Try / Catch? [closed]

Here at work I came across a code that treats an error in an if instead of try / Catch. The programmer justifies that catch interrupts the code, but I believe that a Finally guarantees execution. Can you tell me what would be the best option for...
asked by 22.08.2017 / 17:04
1
answer

Rewrite code using the try-with-resources feature [duplicate]

My problem is to rewrite a code using the try-with-resources feature, as I'm new to the programming world, I'm not able to learn how to do this, which is becoming rather overwhelming because it's apparently simple but I'm not getting it. I...
asked by 25.12.2016 / 16:02