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

"Instanceof" not working properly

I don't know what wrong with this, but instanceof doesn't seem to work. AppError.ts class AppError extends Error { public statusCode; constructor(message, statusCode) { super(message); this.name = this.constructor.name; …
Steven
  • 821
  • 1
  • 10
  • 24
6
votes
8 answers

asp.net mvc custom exception filter to force a return of full view, not partial

I have a custom exception filter that I'm calling by virtue of adding a [CustomExceptionFilter] attribute to my class. It works as I'd like it to, however if the action method is returning a partial view (through an ajax request), the exception…
Kyle
  • 10,839
  • 17
  • 53
  • 63
6
votes
1 answer

Serialize custom exception to JSON, not all fields are serialized

I'm trying to serialize a custom Exception in Java using writeValueAsString() method from Jackson library. I intend to send it by HTTP to another machine. This is working partialy because not all fields are included in JSON after serialize. The top…
alexcorghencea
  • 341
  • 3
  • 12
5
votes
1 answer

Iron Python and VS2010 debugging woes

I'm starting to use IronPython and VS2010 and I'm having trouble with the debugging environment... can anyone point me in the right direction? Note that my python knowledge is less than a week old so my problems could well be self inflicted. The…
user505765
  • 529
  • 1
  • 8
  • 15
5
votes
5 answers

Is it OK to (mis)use Exception.HelpLink to recognize Exception objects?

I'm working on a logging program, and I'd like to avoid processing the same Exception object repeatedly when it is being logged repeatedly because it is percolating up through a nested call structure. So I'd like to be able to format the Exception…
RenniePet
  • 11,420
  • 7
  • 80
  • 106
5
votes
1 answer

How to get content type of the response in JAX-RS ExceptionMapper

I have a resource: @GET @Path("/print-order") @Produces("application/pdf") public byte[] printOrder(@QueryParam("id") Long orderId) { return ...; } ...which can throw an error that is relevant to the user and must be displayed as a HTML page.…
Sašo5
  • 61
  • 1
  • 6
5
votes
4 answers

What are the least requirements to have, to say a custom exception is serializable?

I have bunch of custom exceptions in my solution's legacy code. And I want to test all the custom exceptions introduced in my projects to see if they are Serializable (XML) So, what should my tests check to pass when a custom exception is…
pencilCake
  • 51,323
  • 85
  • 226
  • 363
5
votes
1 answer

catching custom exception in js

If I have following function ValidationException(nr, msg){ this.message = msg; this.name = "my exception"; this.number = nr; } function myFunction(dayOfWeek){ if(dayOfWeek > 7){ throw new ValidationException(dayOfWeek, "7days…
user1765862
  • 13,635
  • 28
  • 115
  • 220
5
votes
2 answers

How do I make config.exceptions_app work with rspec

In my Rails 3.2 app, I'm trying to use config.exceptions_app to route exceptions through the routing table to render error-specific pages (especially one for 401 Forbidden). Here's what I've got so far for configuration: #…
5
votes
1 answer

C++ syntax for custom exception class

I am fairly new to C++ and have found the following code snippet for a custom exception extended from std::exception. The only part I don't understand is the : err_msg(msg) {} after the constructor definition. Can anyone explain why this is not in…
eldereko
  • 53
  • 1
  • 4
4
votes
6 answers

How to know when to use an existing Exception or write a custom Exception?

Thanks for the input on this question, I've decided to go with making my Create() method throw exceptions so as Jon Skeet said, you don't have to handle them everywhere and can just let them bubble up, seems the best approach for larger…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
4
votes
3 answers

Best way to add exceptions in jquery selectors paths

let say i want to bind all items that are under #mainDiv .user Except #mainDiv #exception .user I can think of $('#mainDiv .user').bind('event',function(){ if($(this).parents('#exception').length>0){}else{ // do stuff; …
Toni Michel Caubet
  • 19,333
  • 56
  • 202
  • 378
4
votes
4 answers

User defined exceptions: when do we use them? What is an "exceptional" situation?

I'm sure that this question has been addressed in many best practices books, but still... Most of the times I see examples of wrong usage of custom exceptions, therefore I was wondering what would be a good situation to use them? In particular, at…
Emil D
  • 1,864
  • 4
  • 23
  • 40
4
votes
2 answers

In a unit test, how can the parameter passed to a custom exception be determined?

class AppError(Exception): pass class MissingInputError(AppError): em = {1101: "Date input is missing. Please verify.", \ 1102: "Key input is missing. Please verify.", \ 1103: "Stn input is missing. Please verify."} …
Sam
  • 1,358
  • 4
  • 16
  • 30
4
votes
2 answers

FaultException and custom exception WCF

I have a question on how to send a custom exception as FaultException. It works when I use a system Exception like ArgumentException, but if I change it to my custom exception "TestException" it fails. I can’t get the configuration for the service…
faultEx
  • 43
  • 1
  • 5
1 2
3
16 17