Questions tagged [raise]

237 questions
-1
votes
2 answers

How do I use raise correctly?

Can someone please help me to get some kind of structure in this code? I am new to this. The errors should capture both non-existing files, and files that do not contain rows of four parts separated by ";". The program should look something like…
J. Doe
  • 1
  • 2
-1
votes
2 answers

Cant fire my event from the same class

So I have looked at many places and what I am trying to do is not working, although I seem to be doing what everywhere else says I should. I have the following: private EventHandler statsUpdated; public event EventHandler StatsUpdated { …
pingu2k4
  • 956
  • 2
  • 15
  • 31
-1
votes
1 answer

python2.7--TypeError: exceptions must be old-style classes or derived from BaseException, not str

following code in python 2.7.10 def inputnumber() : x = input('pick a number : ') if x == 17 : raise 'BadNumberError' , '17 is a bad number' return x and when i run this , it gives me TypeError : TypeError: exceptions must be…
pejman
  • 17
  • 7
-1
votes
2 answers

Inserting while raising custom exceptions

if not(my_value < max_limit): print "value of is %g and hence invalid. It can be upto $g" % (my_value, max_limit) raise LimitFailureCheck("Failed due to Incorrect value") I have defined my custom exception as LimitFailureCheck in other…
tryPy
  • 71
  • 1
  • 11
-1
votes
1 answer

How to raise an exception for checking a method present in different module

I have 4 modules. 1. run.py Here I'm doing initialization and setup of class A and Class B. And what I want to do is: try: x = x[0]() except TestFailure as tf: print tf.message where due to for loop, x iterates over class A…
-2
votes
1 answer

re-raise exception in Python

In a very well written and awesome book by Robert Smallshire and Austin Bingham there is the following code: def convert(s): """Convert a string to an integer.""" try: return int(s) except (ValueError, TypeError) as e: …
-2
votes
1 answer

what is the idiomatic way to raise an exception within the exception handler in Python?

What is the correct way in Python of catching an exception, and raising another exception? I.e, I want to catch an exception of type 1, manipulate the Exception object and unconditionally raise a second exception of type 2, so that the calling…
Jim Newton
  • 594
  • 3
  • 16
-3
votes
1 answer

"If at least one of these keys is not in the dictionary, the function should generate a TypeError error." How to do it?

def image_info(**o): print(type(o)) print(o) { 'image_title': 'my_cat', 'image_id': 1234 } info = ( f"\"Image '{o['image_title']}'" f" has id {o['image_id']}" ) return info info =…
-3
votes
1 answer

RaiseEvent on C sharp

I know there is a lot of information about RaiseEvents on internet, but I can't understand them, somebody can help me with a simple example on C#. Thanks very much.
MagnunStalin
  • 94
  • 1
  • 9
-3
votes
1 answer

Passing arguments to `caller` statement in `raise` statement

I cannot follow what caller does in these exception raising statements. raise InterfaceException , "Error", caller raise ArgumentError, " Error", caller[1..-1] I know that Object#caller sets and sends stack trace to upper level in hierarchy. What…
Sukhbir
  • 553
  • 8
  • 23
-3
votes
1 answer

raise Value_Error doesn't work

try: if(a>b): raise Value_Error; else: print("no err"); except "Value_Error": print("value error ..."); else: print("a is smaller"); value error is not getting printed or the raise statement is not raising the…
-4
votes
1 answer

How can I run a c++ script in debug in visual studio code?

I have to run a c++ script in debug on Visual Studio Code, but I'm not able to do it. It says me that It is not able to find the file raise.c Unable to open 'raise.c': Unable to read file (Error: File not found…
Tanozar
  • 49
  • 1
  • 1
  • 4
1 2 3
15
16