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
1
vote
2 answers

Unable to wrap DAO exception in service layer using Spring MVC

I am trying to handle custom exception handling using Spring MVC. DAO layer exception handler by service layer and service layer wrap that exception and handle that exception by Controller exception handler by Spring MVC. Following is my code:…
Harmeet Singh Taara
  • 6,483
  • 20
  • 73
  • 126
1
vote
2 answers

Python Custom Exception Handling

After much googli searching to figure out whats going on, here it is: I have a custom validation exception which takes a request and response class ValidationException(Exception): message = "Caught Validation Exception" def __init__(self,…
mikeyseay
  • 169
  • 1
  • 10
1
vote
5 answers

Exception design: Custom exceptions reading data from file?

I have a method that reads data from a comma separated text file and constructs a list of entity objects, let's say customers. So it reads for example, Name Age Weight Then I take these data objects and pass them to a business layer that saves them…
User
  • 62,498
  • 72
  • 186
  • 247
1
vote
2 answers

Custom Exception Class - Why do we need it?

I was reading about custom exception.. This is what I did. #include #include #include using namespace std; class myBase : public exception { public: myBase() {}; virtual ~myBase(void) {}; virtual…
NJMR
  • 1,886
  • 1
  • 27
  • 46
1
vote
2 answers

custom exception class not printing message in eclipse

I have my class already set. I am looking to catch exceptions on the part where number is set to the next keyboard integer. I need to catch if the number is 1< and if the user enters the number in word form. I created a custom exception class but i…
1
vote
1 answer

Validating exceptions inside methods with Symfony2 and Doctrine

I'm new in Symfony2, so I'm pretty sure this is basic but I can't find the answer on the web, I have an entity persisted in MySql through Doctrine, all of its properties have their own validation rules in the validation.yml. When the form is for…
leoxmb
  • 29
  • 1
  • 6
1
vote
0 answers

How to test Rails 4 app with RSpec and custom exception handling from Railscast #53 (Revised)?

Using this Railscast episode, ActiveRecord::RecordNotFound errors ultimately redirect to the ErrorsController and the /app/views/errors/404.html.erb view. However, I have the following in one of my tests (Item belongs_to List): scenario "item cannot…
robertwbradford
  • 6,181
  • 9
  • 36
  • 61
1
vote
2 answers

recognize string as input and throw exception if not an integer

I'm new to java and was trying to do this program. Basically entering 3 numbers, it will calculate the volume of a cube. If a negative number is typed then it will throw an exception, and also when there are more then 3 input. I wanted it to throw…
user3353167
  • 782
  • 2
  • 16
  • 31
1
vote
0 answers

Set faultCode to SENDER in a custom SoapFault?

I want to throw my own custom exceptions through Spring-WS. I write my Exception class like this : @SoapFault(faultCode = FaultCode.CUSTOM, customFaultCode = "{http://www.myorg.com/test}INVALID_INPUT_DATA") public class InvalidDataException extends…
stieuma
  • 21
  • 3
1
vote
3 answers

Catching custom exception from WCF

I have a Custom class, InvalidCodeException in Project A public class InvalidCodeException : Exception { public InvalidCodeException () { } public InvalidCodeException (string message) : base(message) …
Hataf Moin
  • 161
  • 1
  • 2
  • 9
1
vote
3 answers

Is it bad programming to just throw exceptions while not in a try catch block?

I'm currently working in PHP. I'm working on a error system for my CMS I'm building (for the fun of it). For fatal errors in my system (not in the php compiler) I created a FatalException class that extends the built in Exception class. Since these…
1
vote
2 answers

Custom Exceptions Class Naming in Java

I am trying to create a custom exception class but having trouble naming. Here's what I have so far: public class MyException extends Exception { public MyException() { } } Now, I want an exception that is not called MyException. Can I…
user908015
1
vote
2 answers

PHP Does Custom Exception Handler require try {} catch?

I've written the following custom Exception handler: namespace System\Exception; class Handler extends \Exception { public static function getException($e = null) { if (ENVIRONMENT === 0 && is_object($e)) { …
Spencer Mark
  • 5,263
  • 9
  • 29
  • 58
0
votes
1 answer

Trying to suspend threads after custom exception called

This is a school assignment I have been working on. I've been back and forth with my tutor and he's been helping me with this but there's something I'm obviously missing here. The program in question takes an argument, "-f filename.txt" and in that…
Richard Chase
  • 407
  • 5
  • 21
0
votes
5 answers

C# Windows Forms custom exception problems

I'm trying to get this to throw an exception if year entered in TextBoxCopyrightYear.Text is higher than the current year, but it does not seem to be doing it. The question is... why is it not throwing the exception when I input something higher…
lorenzoid
  • 1,812
  • 10
  • 33
  • 51