Most voted "exception" questions
The exception treatment is the mechanism responsible for the processing of occurrence of conditions that change the normal flow of code execution.
Learn more…329 questions
Sort by count of
-
7
votes3
answers546
viewsRun program inside Try/Catch
Working with Visual Studio, when an error occurs while the program is running the program hangs and you can’t see where the program crashed and only appeared that error screen. To catch where these…
-
7
votes3
answers1618
viewsHow to intercept exceptions when working with the Entity Framework?
I want to handle errors returned by Entity Framework. In this example I am forcing the insertion of a duplicate record (Name already existing in the database and the table column is configured as a…
-
7
votes2
answers5374
viewsHow and when to use exceptions in PHP?
In PHP, most native functions return a boolean false, whole 0 or NULL if some type of inconsistency is found in the value passed to it. Example: $exemplo1 = explode("","tente me explodir"); // false…
-
7
votes4
answers342
viewsWhat is the function of the " | " operator within the catch?
I read that || (OR) is for boolean operations and | (Bitwise Operation) for bit operations. What is your function within a catch with multiple exceptions, then? I mean, I know it eliminates…
-
7
votes3
answers254
viewsWhy validate even with a default value
When I’m preparing something, however simple it may be, the question always arises: I must trust the mine code? This puzzle is usually associated with the fact that "tomorrow" may not be me…
php exception validation software-engineering encoding-styleasked 10 years, 1 month ago Zuul 35,190 -
7
votes5
answers2024
views -
7
votes2
answers189
viewsWhich Exception should I release according to each situation?
In PHP, we have several types of exceptions that can be released. Among them: BadFunctionCallException BadMethodCallException DomainException InvalidArgumentException LengthException LogicException…
-
7
votes4
answers957
viewsIntercept Exception
I am using Demoiselle in my application, but it has not been behaving very well in one aspect. In an association between two or more entities, deleting an exception is made. With the exception…
-
7
votes1
answer3980
viewsIn which cases return the System Exception error.Outofmemoryexception
Which are the most frequent cases that can return this Exception?
-
7
votes3
answers701
viewsWhat to do when the argument passed in the constructor is invalid?
I’m playing a card game in Java, and one of the classes is responsible for starting the game. In the builder, I get the number of players who will participate. I am doing the validation of the…
-
7
votes3
answers189
viewsIs it better to have a kind of exception for each case or a more general exception?
A project from my college was asked to create a class called RepositorioException which is a subclass of Exception to be used for handling exceptions in repository classes, where:…
-
7
votes1
answer1030
viewsBest practices with Java exception handling
How best to work with more than one exception in Java? In the code below, I see the possibility of giving two errors NullPointer or SQLException. If I put one catch for every exception is the best…
-
6
votes1
answer1796
viewsExceptions in Java
I am studying about exceptions in Java and would like to understand better. When declaring an object, if the programmer predicts that a failure may occur in the execution of the method, he will…
-
6
votes1
answer1441
viewsExecution flow of a Try/catch/Finally block
How the execution flow works in a block try/catch/finally in the example below? public class ExceptionTest { public static void makeException() throws ExceptionAlpha, ExceptionBeta, ExceptionGamma {…
-
6
votes2
answers233
viewsIs there any way to handle all Exceptions of the software?
I’m creating a DLL for use in various projects of mine. I created a method that captures Source, Message and other variables that I defined, assembles an email and sends them to myself. (a kind of…
-
6
votes1
answer407
viewsIs it possible to show exception message in en-BR?
I would like my exception message to be shown in English, someone would know how? catch (Exception ex) { Debug.Writeline(ex.Message); }
-
6
votes4
answers742
viewsWhat is the difference between PHP’s "Exception"?
Has several Exception defined in PHP, as ErrorException PDOException Error ArithmeticError, etc.... But what’s the point of having so many exceptions? There’s a difference between using one and the…
-
6
votes1
answer558
viewsTry/catch on JS
I own a array called agenciasUri, which format the data before inserting into it. After that, I mount JSON jsonObjto send a request. What I found strange is that it is working properly. Why can I…
-
6
votes2
answers98
viewsWhy println ran before printStackTace?
I was studying Exception Treatment in Java and I came to this question that I could not find on Google. Why in this example he printed the first line of the printStackTrace, and already gave the…
-
6
votes2
answers152
viewsTreat Exception by code
In Visual Basic 6 there was the command err.number where the error code is demonstrated. I have a C# app that we treat Exception by the description of the message because I did not find the command…
-
6
votes3
answers246
viewsDeal with exception that guaranteed will not occur
Here is an example of a method to illustrate the context of my doubt: public void comprar(int numeroLoja, int numeracaoProduto, String nomeMarca) throws LojaNaoExisteException,…
-
6
votes5
answers497
viewsPrint string in reverse
Why can’t I print that string in reverse? I know there is possibility to use another simpler way, but I want to understand the error. static void Main(string[] args) { string frase = "Diego lima de…
-
6
votes2
answers157
viewsIs capturing Nullpointerexception bad practice?
I’ve been a little uneasy about security issues and vulnerabilities lately, and in my research, I came up with an article that intrigued me. According to the OWASP: Description It is generally a bad…
-
6
votes2
answers245
viewsHow to fire multiple exceptions?
foreach (Foo el in arr) { // ... Validate(el); // ... } In the example code, when the foreach is executed, an exception can be triggered from the function Validate which will be treated on who…
-
6
votes1
answer107
viewsWhat are the advantages and disadvantages of encapsulated errors types like "Result"?
I’m learning Rust and one of the things that made me curious is the absence of exceptions. Unlike languages such as C#, Java, Javascript, etc., which have exceptions, in Rust this does not exist. If…
-
5
votes1
answer717
viewsCapture errors and PHP Exceptions
Setting I know I can configure the logs so that the errors and exceptions are recorded, this is nice, but sometimes it is too boring to read these files. Question How to capture the mistakes and…
-
5
votes2
answers756
viewsHow to use arrays in Java?
It’s a very beginner question (I’m new to Java, I came from C++). I have to do a program that takes 4 grades from 10 students, but when I go to work with the "pointers" (arrays), my program returns…
-
5
votes1
answer363
viewsContinue running the loop even if a passage gives problem
I’m downloading Bovespa’s stock data for the package quantmod. However, I still do not know why, in the data from Santander (SANB11) the function getSymbols package is giving problem and loop for…
-
5
votes2
answers351
viewsHow to recover from an Exception and send data from it?
I wonder if there is any way for when my system launches some kind of Exception it recovers only and sends me an email stating where it occurred and which Exception was launched!
-
5
votes2
answers3052
viewsTry and Catch continue running (after Exception)?
How I put a block try and catch p/ continue the loop for, even if it does arrayindexofbounds and among other Exception? I put and it runs but the output of "m" does not print anything after! for…
-
5
votes2
answers11135
viewsException vs Runtimeexception, when using one or the other?
I was with that doubt, and when I was made aware of it another came to me, which I would like to be clarified. What’s the difference between Exception and RuntimeException? When to use Exception or…
-
5
votes1
answer108
viewsHow to serialize an Exception with closure
I am trying to serialize the error generated exceptions to record a log with all the information, but the problem is that some exceptions may come with a closure within the trace and fire the…
-
5
votes1
answer73
viewsSerialization of exceptions
According to the msdn documentation, an exception should be serialized if it should be propagated outside the Assembler. In visual studio, I have a solution with some projects, among them a class…
-
5
votes1
answer197
viewsFire Asynctask class exception
The class below is responsible for obtaining data from a WCF Rest service: public class MyAsyncTaskGeneric<T> extends AsyncTask<String, Void, T>{ private final Class<T>…
-
5
votes1
answer437
viewsUrllib2, exception handling
I’m a beginner in the art of programming. I’m learning to code in Python through a book, Learning to Program: The art of teaching the computer (Cesar Brod - Novatec Editora) In one of the exercises,…
-
5
votes1
answer19133
viewsHow to create a custom Exception/Exception in Java
Java, brings with it several ready-made Exceptions, Illegalargumentexception, Illegalstateexception, Runtimeexception, among others. Creating a Custom Java Exception? I have the following method -…
-
5
votes2
answers519
viewsWhat are checked exceptions?
While following a discussion about programming languages, I saw people arguing about checked excpetion each with its arguments for or against. They said that such language implements and such…
-
5
votes1
answer86
viewsHow to know which exception can be cast in C#?
If in Java I invoke the method void cadastra() throws SQLException for example, I will be required to add a block try catch or to "relaunch" the exception that can be launched by this method. That…
-
5
votes3
answers3023
viewsCompilation and execution error difference
A build error would be the one the IDE already warns about even before compiling, such as missing a semicolon, correct? But what about the error of execution? It would be for example a Exception?…
-
5
votes1
answer6047
viewsWhat causes the 'System.Nullreferenceexception'?
Time or other the execution of my systems are interrupted by this error, when it happens, a if(atributo != null) It usually does, but it pollutes the code, "Oh, but this variable needs to have a…
-
5
votes2
answers379
viewsHandle 404 error without using Try/catch
I have the following code snippet that makes an HTTP request, only that sometimes the URL does not work, then will be launched an exception by framework. HttpWebRequest request =…
-
5
votes1
answer91
viewsIs it possible to make a mistake that triggers others?
Follow an example: public class Teste { public static void main(String[] args) { func1(); } public static void func1() { try { func2(); } catch (Exception e) { System.err.println("Error 1\n"); } }…
-
5
votes1
answer557
viewsIs it recommended to manipulate rules with "Try-catch"?
We can manipulate errors in various ways, but the one that will use less code and time of the programmer is the try, present in almost all object-oriented languages. But, when should be used try,…
-
5
votes1
answer96
viewsWhat are the criteria for failbit and badbit in a Std::istream?
In a C++ exercise, it is proposed to store a data (numeric, integer - eg.: 4 or -3650) entered by the user through the console. This is an exercise to deal with exceptions and "defensive…
-
5
votes1
answer187
viewsCreate more specific or more generic custom exceptions?
Taking into account that in a project is used the practice of creating custom exceptions, which makes more sense? I mean, make an exception for every possible error predicted in the code by…
-
5
votes2
answers46
viewsInterpretation of Dive into Python on exceptions
Here is an excerpt from page 47 of the book 'Dive Into Python' about exceptions: "...You don’t need to Handle an Exception in the Function that raises it. If one Function doesn’t Handle it, the…
-
5
votes3
answers203
viewsShould I always use Try catch to fix mistakes?
Sometimes when I know something may fail in my system I do a validation using if, equal is below: lista = [1,2,3] #um número que esteja entre os indices da lista numero = int(input(f'Digite um…
-
4
votes2
answers5558
viewsIs there any way to disable Delphi’s "Debugger Exception Notification"?
I would like to disable the function from which Debugger notifies me of an Exception in a code snippet. Example: try Text := CurrToStrF('Erro', ffNumber, 2); except Text := '0,00'; end; During the…
-
4
votes2
answers6870
viewsJboss - "Unable to get Managed Connection for java:/Appds"
The following exceptions are occurring in my application: 10:52:34,506 ERROR [br.com.app.dao.NotificacaoDAO] (http--0.0.0.0-8080-77) java.sql.SQLException: javax.resource.ResourceException:…
-
4
votes2
answers134
viewsHow to use Logicexception from PHP?
I’m studying the handling of errors in PHP, and already know how to use Exception, but I was in doubt about the LogicException, what is its purpose? And how to use it correctly?…