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

Display custom message when constraint is violated PL/SQL

I'm writing a pl/sql procedure. I've got a constraint on a column which doesn't allow values below 0 and above 500. I need to display a custom message if this constraint is violated (eg. "ID out of range"). Currently this is the exception and also…
Brendon Rother
  • 119
  • 4
  • 17
0
votes
1 answer

Printing Multiple exceptions

class TestFailure( ArithmeticError ): pass def failuremsg( test_variable ): if test_variable < 0: raise TestFailure, "TestFailure: Test Variable should not be negative" return( test_variable ) class TestAbort(SystemExit): …
NikAsawadekar
  • 57
  • 1
  • 5
0
votes
2 answers

Java Exceptions: Should an exception contain its message inside or take it as parameter

Whenever I need to define a custom exception, if it's message will not change depending on context, I put the message inside that exception. Like this: public class UserNotFoundException extends RuntimeException { public UserNotFoundException()…
Utku Özdemir
  • 7,390
  • 2
  • 52
  • 49
0
votes
1 answer

Using C++ Boost's format object as an exception member

I'm trying to write an exception class that needs to be thrown when a system call fails. The exception should have a developer message and the errno code, and it's what method should format the developer message along with the error code. The C way…
reish
  • 831
  • 7
  • 18
0
votes
1 answer

How can I print an Exception stacktrace on javascript?

My function acctualy manages some envolved exceptions. Layer 1 re-throws the exception on layer 2. but it doesn't matter... my question is simple this works: throw { name:"RangeWithValues", message:"The result range cells must be…
White_King
  • 748
  • 7
  • 21
0
votes
2 answers

Cleaning up code for a custom exception class in PHP

I'm playing around with custom PHP exceptions for the first time, and would like some help with cleaning up some code. In particular, I'm catching PDO errors, and have written a class to mail myself a stack trace of the errors. The way that I'm…
Eric
  • 1,209
  • 1
  • 17
  • 34
0
votes
2 answers

php pdo catching connection exception with custom exception handler

What im trying to achieve here , is when the pdo connection throws an exception , my custom exception handler takes the message and passes it on so i can catch it with my custom exception handler. try { $mysqli = new…
Zaid Kajee
  • 712
  • 4
  • 9
  • 22
0
votes
2 answers

How do I create n-number exceptions in the same class?

ok, here's my problem. I want to create my own custom exceptions such as 'UsernameAlreadyTakenException'. I can create a single class in a file which extends Exception. My problem is, I'd rather not have 3 - 5 different files for each 'subclass'…
Trevor Tiernan
  • 392
  • 1
  • 3
  • 9
0
votes
3 answers

Cant pinpoint issue of when user inputs number less than 0 for my custom exception

Cant seem to figure this. If user inputs an invalid balance, how can i reprompt them to enter balance again and still continue my program? //EDITED STILL WONT WORK PROPERLY boolean again; while(again = true) { try { …
zeesh91
  • 143
  • 2
  • 2
  • 12
0
votes
1 answer

Creating custom class in java, using try-catch blocks, filewriter and printwriter

Trying to surround this code with a try-catch block. However, upon many unsuccessful attempts i still cant get it to throw my CUSTOM exception message for when a user input a balance less than 0. Im trying to keep it extremely simple for learning…
zeesh91
  • 143
  • 2
  • 2
  • 12
0
votes
2 answers

Python custom exception and sub-exceptions

What is a good way of raising sub-exceptions (is that's the term)? Scenario: I want to raise a custom ConnectivityException when http or ftp exception occurs. Is there any way to raise ConnectivityException such that exceptions are categorized…
AccurateEstimate
  • 363
  • 2
  • 16
0
votes
1 answer

Custom Exception (RuntimeException)

I want to make my own exception. But when I throw my exception the program is close. So how can I run my method 3 times and after that close the program. (my program closed after intArray, but I want to go through dobleArray and charArray) Here is…
user3079114
  • 69
  • 1
  • 12
0
votes
2 answers

Which type of exception should be generalized or created a base class for in a Java architecture

As a team lead which type of exception should I create a base class for in my architecture - checked or unchecked ? My team would start development in a few weeks and I want the architecture to be conducive to them for usage. Any reasons around that…
0
votes
2 answers

Java Error: Unreported exception?

I've got the following method: public T peek() throws StackEmptyException { Node tracker = head; while(tracker.getNext() != null) { tracker = tracker.getNext(); } return tracker.getItem(); } The problem is that when I…
Vimzy
  • 1,871
  • 8
  • 30
  • 56
0
votes
1 answer

Can't get transaction data older than 7 months from customer account data api with developer account

I am using a free development account, rails 4.0, ruby v2, heroku toolbelt, redis-server, and postgres 9 I have a rails app that had been loading transactions from Aug. 2013 to Feb. 2014 this past Feb.. In March the app loaded back to Sept., saw…