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

How should I handle this particular exception in C#?

I have a class called "Website", and inside of that class I have the following property: public HtmlForm RegisterForm { get { if (Forms.RegForm != null) / Forms is a custom object called HTMLForms that is a custom list collection …
codygman
  • 832
  • 1
  • 13
  • 30
0
votes
6 answers

Throwing custom Exceptions, if for loop

public class StringArray { private String strArr[]; public StringArray(int capacity) { strArr = new String [capacity]; } public int indexOf(String s) throws StringNotFoundException { for(int i=0;i
user3078379
  • 19
  • 2
  • 6
0
votes
1 answer

Throw exception and getting e null

I throw a exception with some message like: public static ILSResponseEmailLookUPBO getILSUserAccounts(Resources res, String email) throws TripLoggerCustomException, TripLoggerUnexpectedErrorException { String resp = null; …
user2106897
  • 529
  • 1
  • 5
  • 11
0
votes
5 answers

How to Catch Custom Exception

I have the following code in the 'main' method: static void Main(string[] args) { try { int a = 0; int b = 5; b /= a; } catch (MyException ex) { Console.WriteLine(ex.Message) } } And…
yazanpro
  • 4,512
  • 6
  • 44
  • 66
0
votes
3 answers

Why is the custom exception I created causing a non-static variable error?

Can somebody please explain what is going on here? Why is the "non-static variable this cannot be referenced from a static context." appearing in this code? I have tried changing the parseBinary to non-static. I have tried changing the…
user1690995
0
votes
1 answer

Make custom exception throw automatically

I have created a custom-exception that i want to throw whenever a user enters a sex that is either male of female. I did this using class sexException : Exception { public override string Message { get { return…
user2509901
0
votes
0 answers

Catch custom exception in web.xml

How do I create a custom Exception and handle it in web.xml with the error-page tag direct it to a specific page. I have tried to create a exception extends the servlet exception like this. public class MyException extends ServletException { …
Tech Noob
  • 510
  • 1
  • 9
  • 33
0
votes
1 answer

Custom Exception without new throw in .NET

I am not sure if this is at all possible. (I think it should). Would it be possible to catch a customexception without throwing new one as follows? try { //Some logic which throws exception } catch…
activebiz
  • 6,000
  • 9
  • 41
  • 64
0
votes
1 answer

Interview_Question on Custom Exception in C#

I faced a question on Custom Exceptions in an Interview. As below there are four multiple catches which catch each custom exception. Interviewer asked me to write a pseudo code for catch blocks how i can handle all four custom exceptions. I…
venkat
  • 5,648
  • 16
  • 58
  • 83
0
votes
4 answers

Clarification : Try Catch vs Throw the exception and why call base class constructor

Following the example in book and got the following slightly modified code: class OutOfHoneyException : Exception { public OutOfHoneyException(string message) :base(message){} } class HoneyDeliverSystem { public void…
Simsons
  • 12,295
  • 42
  • 153
  • 269
0
votes
2 answers

Custom Exception with WCF

hey i am using Oleg Sych's solution for handling exception via WCF: link everything works well with Known Exceptions (such as InvalidOperationException and SystemException) but when i am trying to use my own custom exception, it doesnt work and i…
Ori Price
  • 3,593
  • 2
  • 22
  • 37
0
votes
1 answer

g++ custom exception handler

Would it be possible to install a custom handler for GCC? I'm trying to throw a wrapper class to a pointer (like shared_ptr) and then catch it covariantly. This is actually for my Managed C++ for GCC project (on sourceforge) but to illustrate the…
Zach Saw
  • 4,308
  • 3
  • 33
  • 49
0
votes
2 answers

bubling up the exceptions in PHP?

Supposing I have this scenario: function1() call to function2(), and function2() call to function3(). if function3() throws an exception, can I capture the exception from function1()? And in the case in which maybe, some of these functions is in a…
itaka
  • 399
  • 1
  • 5
  • 16
0
votes
1 answer

Is it a good practice to use "die()" when dealing with custom PHP Exceptions?

I've wrote a custom exception class in PHP:
user1386320
0
votes
5 answers

New exception class the extends exception class and has two constructors

Create a new exception class IllegalDimensionException that extends Exception class. It will have two constructors, one default- value and one explicit value that uses the message "Illegal dimension for the figure you specified. Does this seem to be…
Chaz32621
  • 127
  • 1
  • 12