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

WebProtocolException was unhandled by user code

The code in my try block looks something like below: catch (ThinkBusinessLogicException ex) { var message = (ex.InnerException != null) ? ex.InnerException.ToString() : ex.Message; if (message == "CustomerID in A does not match customerId…
Zal
  • 43
  • 3
0
votes
4 answers

How to display my own exception?

I'm developing a web project where i need to add custom exception classes. For example, how can i display a message from my custom exception class when the session timeout occurs? Please help. Any sample will be helpful. This is what i written in my…
NewBie
  • 1,824
  • 8
  • 35
  • 66
0
votes
1 answer

Serializable custom exception class?

Google App Engine requires me to make objects serializable before I can use it as a session bean. Now I have a Product class, I made this Product class serializable, but one of its constructors and some setters have checked exceptions, these checked…
user477768
0
votes
1 answer

Custom exception hierarchy in Scala

I've been reading up on how to properly handle (Option, Try and Either) and define exceptions in Scala. My question is: do exception hierarchies make sense in Scala? For example, we currently have a Scala project implementing something like: class…
Daniel Severo
  • 1,768
  • 2
  • 15
  • 22
0
votes
0 answers

Updating Message in CustomException

I have ASP MVC web application and trying to setup error logging where i am trying to display UI friendly message for web and log more detail message in database in need. My application might not need to log error message in DB always but i wanted…
sanjeev
  • 765
  • 1
  • 7
  • 15
0
votes
1 answer

Can i define methods in exception classes other than __init__ in Python?

As the question already asks, I'm aware of building a custom exception class like this: class MyException(Exception) : def __init__(self, message='My error message') : self.message = message super(MyException,…
lupodellasleppa
  • 124
  • 1
  • 1
  • 11
0
votes
0 answers

Generate a specific HResult value of Exception that must be caught in COM

I need to thrown an exception from C#.Net application and catch it in COM to process an error massage for my app. I would like to know is there any accessible range of values of HRESULT that can be used for specific exception? Or it's OK to pass any…
programmer0
  • 147
  • 7
0
votes
0 answers

Java Throwing exception with parameters (Exception e, String... errs)

I am trying to write a custom exception class for a program that connects to a local MySQL database and throws an exception if we are unable to connect (bad database, username, or password). However my professor put a weird requirement in for my…
Ryan
  • 262
  • 3
  • 19
0
votes
2 answers

How to display my own FileNotFoundException message

I'm having a problem with custom exception throwing in Java. Specifically, I'd like to intentionally throw a FileNotFoundException in order to test a method called fileExists(). The method tests if the file (A) doesn't exist, (b) is not a normal…
0
votes
0 answers

Java- Issue with try-catch exception inside custom exception

I have a custom Java exception class, CustomRestException: import org.codehaus.jettison.json.JSONObject; public class CustomRestException extends Exception{ private String httpStatusMessage; private Integer httpStatusCode; …
A Nice Guy
  • 2,676
  • 4
  • 30
  • 54
0
votes
1 answer

Getting an error when throwing a custom exception from a property

Within a NeuralNetwork class, I've defined the nested class public class TrainSetCardinalityMismatch : ArgumentOutOfRangeException This is to be thrown when a user tries to provide a training set that does not have the same number of elements as…
0
votes
1 answer

Custom Exception thrown in Java should be shown in Thymeleaf

I want to show my custom exception that is being thrown in Java code in Thymeleaf. @Override public UserDetails loadUserByUsername(String benutzername) throws UsernameNotFoundException { Benutzer benutzer =…
Bernd
  • 593
  • 2
  • 8
  • 31
0
votes
1 answer

Ruby rescue custom exception

In following example: class Foo class MyCustomerror < StandardError def message "My custom error" end end def self.do_standard 1 / 0 rescue StandardError => e puts e.message end def self.do_custom 1 / 0 rescue…
Costy
  • 165
  • 2
  • 14
0
votes
1 answer

Spring Boot JUnit test case to test custom exception is throwing AssertionError instead of CustomException

I am testing a Spring boot MVC application which takes MultipartFile as input. My service class will throw a custom exception when the file format is other than .json. I've written a JUnit test case which tests this scenario. Instead of throwing my…
Thiagarajan Ramanathan
  • 1,035
  • 5
  • 24
  • 32
0
votes
1 answer

Symfony 2 - In production not return POST Json custom message exception

I'm using Symfony 2.8 I have a POST method root. The return format is json. app_patient_create: path: / methods: [POST] defaults: _controller: App:Patient:create _format: json _angular_safe: true In a Listener in this root, i have an…
Bruno P.
  • 51
  • 6