Questions tagged [custom-exceptions]

Custom Exception inherits the properties from the Exception class. Whenever we declare our own exception, it is known as custom exception.

Custom Exception inherits the properties from the Exception class. Whenever we declare our own exception, it is known as custom exception.

242 questions
0
votes
1 answer

Combining Multiple Exceptions in Custom Exception : Optimization

I have few similar methods and there calls as follows : methodThrowingException() throws NullPointerException, InterruptedException, TimeoutException { } Calling class : try{ methodThrowingExceptions();
Naman
  • 27,789
  • 26
  • 218
  • 353
0
votes
3 answers

How to gain program control back after handling the exception?

 am developing a python application . I have validated customer id from database. Means if the entered custid is present in database, i am raising an exception. In exception class i am printing the message . So far it is printing the message. But i…
Bhushan Gadekar
  • 13,485
  • 21
  • 82
  • 131
0
votes
1 answer

Custom Exceptions and Message Dialog in Try-Catch clause

I develop an Universal App that need several custom exceptions to catch errors encountered when calling webservices: NoInternetAccessException, NoJSONException, UserTimeoutException, ... Here is an example of one of these classes: public class…
Gold.strike
  • 1,269
  • 13
  • 47
0
votes
4 answers

Creating your own exception and use it in C#

I am trying to understand how to use a custom exception in the right way. I have used try/catch many times but never understod when to use your own class off exceptions. I have read and watch some off the many tutorials out there, but I can't get my…
Newbie1337
  • 199
  • 1
  • 12
0
votes
1 answer

Sending custom Exception Details with the Response in OData2

I am working in a web service project where olingo, odata2 are used with Java . I am using factory class that extends ODataJPAServiceFactory. I want to send custom status code and message in case any exception happens in the module. But can not find…
0
votes
2 answers

Exception is not being captured

I have a program where you can input name, surname, id and export them to a text file. The file can be imported back by using a load method. The problem with the load method is if you press the load button and don't select a file the list of errors…
Ryan Theuma
  • 33
  • 10
0
votes
1 answer

Custom Exception for a load method

I created a custom exception so that when I browse for a file and close the browser, I catch the error and tell the user "Please Select a file": public class CancelException extends Exception { public CancelException() { } public…
Ryan Theuma
  • 33
  • 10
0
votes
1 answer

Where to have the Handlers for Custom Exceptions

I have 2 custom exceptions defined in my project. Each of which should be handled differently. Exception A { errCode } Exception B { // other stuff errCode } The main caller method, is like this. Should the code to write into the tables be…
arkabhi
  • 68
  • 5
0
votes
2 answers

How to identify generic objects in exception logs?

I have a helper method that accepts parameters with generic types. This method can throw exceptions, which I log in order to debug later. Some objects have ids, some have names, etc., that would be useful to know when trying to debug. How can I log…
Jason
  • 506
  • 3
  • 14
0
votes
1 answer

On creating custom exceptions

How are Exceptions in java defined and how can I define my own? As an example, we have ArithmeticException which prohibits us dividing by 0 and does not break the program. What is try-catch's advantage to catching the same potential error with an…
AlvinL
  • 438
  • 5
  • 24
0
votes
2 answers

I can't get my method to throw a custom exception

I have a class ProductionWorker with the superclass Employee, that I created for a school project. We are supposed to set up exceptions for it this week and I keep getting an error when trying to create one of them. Here's my code: in…
0
votes
3 answers

exception (handling) in c#

catch (Exception ex) { _errorCode = ErrorCodes.SqlGeneralError; CommonTools.vAddToLog(ex, _errorCode, _userID); throw new JOVALException(_errorCode); } I use this peace of code to handle error to an custom exception called…
Raed Alsaleh
  • 1,581
  • 9
  • 27
  • 50
0
votes
2 answers

C# Placeholders in Exceptions

Stupid question but I really can't find the answer of it. How can you insert a place holder in the the exceptions like this? And is it even possible? public int Age { get { return this.age; } set { this.age =…
0
votes
1 answer

Can we throw a custom exception from catch block?

I want to throw a custom exception from catch block, i.e., whenever any exception occurs it should catch by catch block and will throw a custom exception. I am trying with the below code but getting runtime exception in catch block as "unhandled…
Anand
  • 823
  • 1
  • 10
  • 19
0
votes
3 answers

Throwing Multiple Exceptions

I have a Java Application code that has following custom Exception structure SettlementException extends Exception PolicyMissingException extends SettlementException PolicyExpiredException extends SettlementException I have some try/catch blocks…
Bhavna
  • 117
  • 1
  • 2
  • 13