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
-
3
votes1
answer167
viewsCapture and treatment of exceptions in a generic way
In general the most common is to capture the exceptions specific and do some treatment with it, right? Example: try { //Algum trecho de código } catch (MyException myException) { //Especifico para…
-
2
votes1
answer405
viewsHow to capture errors and exceptions to send to BD with PHP?
How can we capture all errors and exceptions generated at runtime in PHP, sending to the database to later make an organized log page? Currently I redirect all requests to index.php, treating the…
-
2
votes1
answer73
viewsWhich errors trigger the catch?
In a test similar to this, I was in doubt of what mistakes generate the Exception. Researching I only found explanations of the use of try, catch, and some references that this would depend on the…
-
2
votes1
answer4074
viewsThe 'X' type initializer has triggered an exception
While trying to run the line below, I get the following error message: An Exception of type 'System.Typeinitializationexception' occurred in Programa.exe but was not handled in user code. Additional…
-
2
votes0
answers33
viewsWhat is the possible cost of using blocks for exception treatment in too ?
As exceptions are interruptions caused most of the time by the operating system, I wonder if there is any cost of memory (stack/heap) since, existing exception treatment the program continues to run…
-
2
votes3
answers467
viewsWhat is the best method for exceptions?
What’s the best method to pick up exceptions in an Android app, like try/catch, throws or throw. Type exceptions, fields the user left blank in a form.…
-
2
votes1
answer144
viewsNullpointerexception occurring
My teacher uses the technology of EasyAccept as validation of errors. In one of the tests it is necessary to use Exception. In the code below, I managed to treat in a way that I THINK is…
-
2
votes2
answers1047
viewsError while running project in Visual Studio
When I run a project in Visual Studio it shows the following error: A first chance Exception of type 'System.Data.Sqlclient.Sqlexception' occurred in System.Data.dll Code using System; using…
-
2
votes1
answer701
viewsWindows Service 'System.Typeinitializationexception' on startup
Hello, I am creating a windows service to perform a backup job. I have created other services before but never had a similar problem. Everything was going well, during the development I installed…
-
2
votes1
answer77
viewsCode snippet in Try
I was making corrections in a class and I came across the following code, I didn’t know it was possible and I never stopped to think, but why is this valid? I mean first line of the Try. For me…
-
2
votes1
answer515
viewsException Handler having return in JSON
I’m building a Restapi using Laravel/Lumen, in tests can occur the return be totally in HTML, this occurs when it appears that already famous screen: Whoops looks like Something Went Wrong This gets…
-
2
votes0
answers64
viewsFilenotfoundexception being launched in Twitter search - Java
I have an algorithm that does a search of old tweets on Twitter between two dates. My goal is to return all tweets. The code was as in this question posting (may serve as a parameter) a few days ago…
-
2
votes1
answer130
viewsLaunch an error with trigger_error or Exception in a different scope
Suppose I have a function in a file called foo.php: <?php function foo() { trigger_error('Olá mundo!', E_USER_ERROR); } And in the index.php file I would use it like this: <?php require…
-
2
votes1
answer89
viewsWindows service for after Exception
Is there any way to make a Windows service created on c# don’t give Stop() after a Exception? The service was created with a timer, which will run every 1 hour, but there was an error in the…
-
2
votes2
answers102
viewsHow to display the attributes of an Exception in Python?
I’m doing some exercises with exceptions created by me in Python but I don’t really understand this part of attributes in exceptions. I wanted when the code fell on Exception, it would show a…
-
2
votes2
answers55
viewsCan you add the keyword "noexcept" in get/set methods?
Is there any problem in adding to keyword noexcept in methods getters/setters of a class that only returns or changes values of simple variables (bool, int, float, double, etc..)?…
-
2
votes1
answer36
viewsWhy is it possible to delete an exception "release" statement from the signature of an inherited method?
I would like to know because I did not understand this part, it is because it is a statement that it can "launch" an exception? //EXEMPLO public abstract class Personagem{ public abstract void…
-
2
votes2
answers66
viewsCost of using exceptions with PHP and Valueobjects
I have always heard that exceptions have a high processing cost and make the application slow. In the specific case of PHP, how much can we abuse the use of exceptions? In the case of data…
-
2
votes1
answer374
viewsHow to test java exceptions using spring and Junit 5 lib?
I’m in doubt about how to test my java exceptions using the Spring Framework’s own resources. I’m testing a class called UsuarioValidator.java and in it I have a method called…
-
2
votes1
answer42
viewsIs it possible to declare that in a function you launch an exception with PHP?
With a small example: public function calcularMedia($valor){ if($valor < 0){ //LANÇAR EXCEÇÃO } else if($valor > 6){ return "Passou"; }else{ return "Recuperação"; } } Remembering this function…
-
2
votes1
answer221
viewsCall methods and catch exception
I created three classes, an abstract class called Form, a class Retangulo extending Forma and a class programa, containing the method Main. My intention is in the "program" class to receive the…
-
2
votes1
answer157
viewsWhy is it not possible to capture exceptions triggered by async void?
Why it is not possible to capture exceptions triggered by non-recurring asynchronous methods Task? public async void calcularPrecos() { var tabelaPreco = await getTabelaPreco(); /* Blá, blá, blá...…
-
2
votes1
answer96
viewsGet exception name in Python where it is not specific
I’m using the exception Exception, but wanted to be more specific and take the correct exception, without the treatment the code returns me the following message: F: Bel Desktop…
-
2
votes2
answers697
viewsClasscastexception error when trying to cast between classes
I have the problem to perform a "Cast" in a class, when using the inherited class method of the following error: "entity. Aula cannot be cast to tableview.Aulatv" Here gives the exception described…
-
2
votes2
answers645
viewsWhere should I place the Try/Catch blocks using MVC?
I am making a web application in java and I have some doubts regarding the block Try catch, I am using the standard MVC and I have the following codes: Controller: try { String pesquisa = "%" +…
-
2
votes1
answer4068
viewsHow to show error message?
I am developing a C# register in Visual Studio and created a method to include a new record in the database. The method is as follows:: public static bool Inserir(Usuario pUsuario) { try {…
-
2
votes1
answer122
viewsTreatment of exceptions of different types
try { await DoFooAsync(); } catch (Exception e) { if(e is TaskCancelledException || e is UnauthorizedAccessException) { // ... } throw; } The block catch from the above section checks the type of…
-
2
votes1
answer853
viewsCan the use of Try in Delphi when misused be a trap?
Once a programmer saw my codes and praised me for making use of Try, I confess that I was not thrilled by the praise for finding that the use of Try is not a simple way to solve exceptions, I see…
-
2
votes1
answer60
viewsError debugging by null on connection
I want to document a unit test but I’m getting error: System.Exception: 'Error closing database connection: Undefined object reference for an instance of an object.' My test case was so coded: using…
-
2
votes1
answer360
views.jar cannot find the path to the ireport reports
Good afternoon Gentlemen! I have a problem and none of the other posts could help me... I was checking my TCC and I just came across the following problem: My executable. JAR cannot identify the…
-
2
votes3
answers1274
viewsHow to troubleshoot the error: Reflectionexception (-1) Class App Http Controllers admin Ufcontroller does not exist
Follow the code snippet route/web.php //Gerenciar UFs $this->group(['middleware' => ['auth'], 'namespace' =>'admin','prefix'=>'ufs'], function(){ //Inicio das Rotas de gerenciar os UFs…
-
2
votes1
answer47
viewsHow to use RAII, Constructors and Exceptions
I’m new to C++ and recently came across something that I can’t quite understand, which is: in my research, I saw that RAII is a suitable technique to be used when you need to acquire a resource in…
-
2
votes0
answers36
viewsWhat is the best way to use Firstchanceexception in multithreading application?
I have an application (which is a Windows service) that currently runs N Threads. What I want to do is capture whichever error that occurs in the application to write to a log file '.txt'. Only I…
-
2
votes1
answer68
viewsHow to use Try with while and vectors
I need to create a code where the user enters 4 whole numbers and if anything else is typed an exception treatment. I’m having problems with the catch, I’m not able to do that when the exception…
-
2
votes1
answer65
viewsHow to implement java exception handling within a swtich-case?
I have to do a treatment for possible exceptions within a calculator, one of them would be the division by 0, in the case "Arithmeticexception", but I’m not able to make it work, even after…
-
2
votes1
answer59
viewsError handling is not occurring
In the code below I treated the error only that after treating it still appears the quantity name (I sent the photo below to facilitate understanding). How do I make him not show the quantity name?…
-
1
votes1
answer698
viewsSession is closed! Spring + JPA (Hibernate)
I’m trying to make an example of JPA + Spring. But I’m having trouble managing transactions. persistence.xml: <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0"…
-
1
votes1
answer398
viewsWeb API 2 - Use of Reasonphrase in exception handling
var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { ReasonPhrase = "Nenhum produto encontrado" }; throw new HttpResponseException(resp); That code should return 404 No products found But…
-
1
votes1
answer2214
viewsDisplaying error messages in a web application
I have developed a simple web application to study some concepts related to Servlet among others. I mapped the file web.xml of my application to display a página de erro in case an exception occurs.…
-
1
votes1
answer1051
viewsProcessing of database exceptions
How to handle database exceptions with JPA? And, how to use annotations instead of the Imessage interface, as below? Example: My database returns error: "Violation Constraint uk_email"; Pick up the…
-
1
votes1
answer530
viewsMaking exceptions in the Eloquent ORM Observers
I have the following code in my model: public static function boot(){ parent::boot(); // Não deixa excluir caso possua registros vinculados. static::deleting(function($content_area){ if($total =…
-
1
votes2
answers455
viewsList of Exception PHP errors
Where can I find a list of error codes for exceptions of try catch in PHP?
-
1
votes1
answer918
viewsReturn Exception Java to Ajax
all right? I’m working on a project, and the back-end (java), is totally separated from the front-end, and they communicate through REST. I have a big question about the exceptions. For example, an…
-
1
votes0
answers32
viewsHandle PHP build error
I am developing a web system in PHP with MVC and Smarty. But I am having the following problem. My system when entering an Exception it automatically opens a call already with the error (inserts a…
-
1
votes1
answer86
viewsInstruction throw is making the system inconsistent
I have a Try.. catch and catch the fellow who did let only throw. catch(){throw;} Well, my intention is to treat all that exceptions and not just let throw. But since I just got here at the company,…
-
1
votes0
answers22
viewsConvert to Brazilian Cities Class
Gentlemen, I have two combos in one form, the first of which is loaded with the Brazilian states, via routine database. It is passed the acronym of the state chosen for a routine in my control,…
-
1
votes2
answers811
viewsRecord and recover information in files
How do I write data to a file and then recover it? I have a enrollment system. I start a folder in Windows and within it I generate the enrollments sequentially. I finish and go home and the next…
-
1
votes1
answer488
viewsHow to pass exception message to an HTML page from a JSP?
I have a college exercise where I have to create a page. jsp that takes as parameter an "id" and runs a query to delete the record within the class products with this id and in case of any exception…
-
1
votes1
answer254
viewsException when searching in Sqlite bank
12-10 09:25:36.029: D/dalvikvm(21543): VFY: replacing opcode 0x6e at 0x0002 12-10 09:25:36.279: I/Adreno-EGL(21543): <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: () 12-10…
-
1
votes2
answers841
viewsWhat exceptions should I capture in a Try-catch?
I have some doubt in try catch in relation to which types of exceptions put. In this example either would be the best option? try { String folerPath = Environment.getExternalStorageDirectory() +…