Questions tagged [raise]

237 questions
8
votes
1 answer

Raising exceptions without 'raise' in the traceback?

Possible Duplicate: Don't show Python raise-line in the exception stack Built in exceptions like NameError etc. give me a traceback to the point in my code where the exception occurred. I'm working on a utility module and it bugs me that if code…
underrun
  • 6,713
  • 2
  • 41
  • 53
7
votes
3 answers

What's the syntax (=>) used in assign error object to variable of `rescue` method?

The rescue which could assigns a variable to reference the error object has this syntax (=>) rescue => e If rescue is the one of the general method call, what's the meaning of =>. Could I use the same syntax on other method call? my_method arg1,…
steveyang
  • 9,178
  • 8
  • 54
  • 80
7
votes
1 answer

How does ruby's rb_raise stop the execution of the c function calling it?

If you write a ruby method as a function in C that uses rb_raise, the part of the function after the call will not get excecuted and the program will stop and you will think that rb_raise used exit(). But if you rescue the exception in ruby,…
Adrian
  • 14,931
  • 9
  • 45
  • 70
7
votes
1 answer

@throw NSException vs NSException raise

What is the difference between @throw NSException and NSException raise? I wonder which one I should rather use (there is a proper use case to use one) and why?
KlimczakM
  • 12,576
  • 11
  • 64
  • 83
6
votes
3 answers

How to raise Suds.WebFault from python code?

I am trying to raise a Suds.WebFault from python code. The __init__ method\constructor takes three arguments __init__(self, fault, document). The fault has fault.faultcode and fault.detail members\attributes\properties. I could not find out what…
neel
  • 61
  • 1
  • 2
6
votes
1 answer

How to get the stacktrace for the original exception in oracle PL/SQL from a RAISED exception?

I'm having an issue where the original stack trace gets lost when I catch an exception, then raise it. Exception gets thrown in proc_a Catch the exception. Perform a rollback. RAISE the exception. Catch the exception (parent block) Print Stack…
ScrappyDev
  • 2,307
  • 8
  • 40
  • 60
6
votes
1 answer

Does RAISE NOTICE 'text' in triggers slow down queries in Postgresql?

When I'm testing my query triggers, I see that the query execution time increase when I'm putting a lot of "RAISE NOTICE ... " in the trigger code. Does this time increase also when I'm calling this queries in my softwares without displaying output…
Andrea Cattaneo
  • 568
  • 1
  • 6
  • 18
6
votes
4 answers

Exception libraries for C (not C++)

I am rolling my own exception library for C and would like good examples to examine. So far, I have been looking at David Hanson's: http://drhanson.net/work/ But I know I've seen other ones available in the past. Can you send me some additional…
Setjmp
  • 27,279
  • 27
  • 74
  • 92
5
votes
0 answers

Python logging termination

The problem What is the best way to deal with situation that I want to log an exception to console, file, etc. and then terminate the program? Suppose I read in a config and validate whether the entries given make sense. If not, I want to raise an…
Matt
  • 435
  • 4
  • 17
5
votes
1 answer

RSpec and Open-URI how do I mock raise a SocketError/TimeoutError

I want to be able to spec out that when Open-Uri open() calls either timeout or raise an exception such as SocketError I am handling things as expected, however I'm having trouble with this. Here is my spec (for…
DEfusion
  • 5,533
  • 5
  • 44
  • 60
5
votes
2 answers

How to report an exception for later

I have a python file in which i have two functions that each of them raise an exception. def f(): raise e1 def g(): raise e2 My question, is it possible to store these exceptions in a variable, like list for example--[e1, e2]--, in order…
LChampo
  • 77
  • 1
  • 8
5
votes
0 answers

Python. Raise exception from multiple exceptions

I can raise an exception from another exception in order to provide additional information, e.g.: try: age = int(x) except Exception as ex: raise ValueError("{} is not a valid age.".format(x)) from ex Is there any way to source from…
c z
  • 7,726
  • 3
  • 46
  • 59
5
votes
1 answer

Racket test for Exception

I am taking my first steps with exception handling in Racket and would like to write a unit test, which checks, if a procedure raises an exception for a specific input. The following is what I already have: The procedure, which shall raise the…
Zelphir Kaltstahl
  • 5,722
  • 10
  • 57
  • 86
5
votes
2 answers

Rails share code between migrations (aka concerns)

I have a few migrations within identical helpers private def add_earthdistance_index table_name, options = {} execute "CREATE INDEX %s_earthdistance_ix ON %s USING gist (ll_to_earth(%s, %s));" % [table_name, table_name, 'latitude',…
Arsen
  • 10,815
  • 2
  • 34
  • 46
5
votes
3 answers

How to DRY up my ruby exceptions in initialize method?

I'm writing a program in Ruby with a Product class. I have some exceptions raised whenever the Product is initialized with the wrong type of arguments. Is there a way I can DRY up my raised exceptions (am I even referring to those correctly?) I…
Brian
  • 310
  • 4
  • 9
1 2
3
15 16