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
1 answer

How do I send a custom parameter to a custom exception in Laravel?

I want to send my own parameters into custom exception using throw new CustomException. I've defined my own error codes into Config and these are necessary for me. public function saveMenu($data){ $validatedData = Validator::make($data, array( …
d.k
  • 147
  • 1
  • 4
  • 15
1
vote
2 answers

My custom exception is not returning the exception code ( code is return 500 always)

I have a strange problem. I have build a custom exception class and i throw that exception in a try catch block. below are my code samples. Please help me to figure out this problems. These are my exception codes. public class DWExceptionCodes…
1
vote
1 answer

Cannot Make Custom Exception Class Constructor with Custom Properties

I'm not understanding the compile errors I'm getting when I try to set the following constructor for a custom exceptions class: [Serializable] class AuthenticationException : Exception { public int PracticeID { get; set;…
W.Harr
  • 303
  • 1
  • 4
  • 15
1
vote
3 answers

Exceptions in PHP. How to use them? How to extend 'em?

Few days ago I deal with errors like this... exit( 'Error!' ); or exit( 'Error!' ); Doh, right? =] Now I'm trying to learn Exceptions. This is how far I got... http://pastie.org/1555970 Is that correct use of them? It would be cool that I can have…
daGrevis
  • 21,014
  • 37
  • 100
  • 139
1
vote
5 answers

Logging user-defined exception C#

Hello I would like to write my userdefined exception to a log file. So Instead of throwing my exception I would like to log that message into a txt file. The constructor for my exception looks like this: public OpenFileException(string pathToOpen,…
user602996
1
vote
0 answers

Catching custom python exceptions both inside a package and as a package user

I'm developing a multi-level package in python: /mega_package __init__.py a.py /medium_package __init__.py /internal_package __init__.py exceptions.py Inside the exceptions.py module I have a…
bobibanai
  • 11
  • 1
1
vote
1 answer

Java, Mule - Throw different types of exceptions on one Validation component

In a flow I've designed, I have a Validation component with a custom validator that references a class, DataValidator, implementing the mule Validator interface. In the DataValidator, I validate several properties and would like to throw different…
Luis Costa
  • 330
  • 1
  • 14
1
vote
1 answer

Can I put multiple exception classes in a single java-file and call them as needed?

Please see my custom exception file (ExceptionHandler.java) below: package utilities; public class ExceptionHandler { public void browserException() throws BrowserException { new BrowserException(); } public void…
abhi17
  • 33
  • 6
1
vote
4 answers

Silverlight exception (faults) handling from wcf service

I want get exeption code from wcf method but i always get NotFound error. Client Side: public MainPage() { InitializeComponent(); client.TestCompleted += new…
Ievgen
  • 4,261
  • 7
  • 75
  • 124
1
vote
2 answers

call base class version method while override the class forcefully, otherwise throw exception

I want to throw a custom exception if override method does not call its super method explicitly. if any class extends class A and override say() method, should call super.say() forcefully to execute code written in base class method , if fails, I…
1
vote
1 answer

Throw custom exception PDO

Is there a way to setup a Pdo object to throw a custom exception instead of the default PDOException? For example: class MyCustomDbException extends PDOException{} $pdo = new Pdo("mysql:host=localhost;dbname=myapp", "user_name",…
CarlosCarucce
  • 3,420
  • 1
  • 28
  • 51
1
vote
1 answer

Will this be considered as an example for custom Exception?

Can the following code be considered as an example for custom exception? If not, can you please explain why from your point of view? public class UseJDBC { public useJDBC() throws Exception { throw new Exception("ABC"); } …
1
vote
1 answer

Python - Implementing Custom exceptions

I have a project that I need to run and have no idea how to implement custom exceptions. It mostly does complicated scientific functions, to be vague. Mostly it will be raising exceptions if something is not set. I've been given this as a starting…
cc6g11
  • 477
  • 2
  • 10
  • 24
1
vote
1 answer

am developing API in java so i need to handle exceptions my customException class extends which class either Exception or Runtime Exception

my class extends which class please give me suggestion public class MyException extends Exception { public MyException (Exception ex) { super(ex); } public MyException (String message) { super(message); } …
Chandu D
  • 505
  • 3
  • 17
1
vote
2 answers

Custom Exception: customize message before call the base constructor

I defined this custom exception public class ThirdPartyServiceException : System.Exception { public ThirdPartyServiceException(string message, Exception innerException): base(message, innerException) { } } That's fine, but now I want…
DevT
  • 1,411
  • 3
  • 16
  • 32