Posts

Showing posts with the label exception

Try / catch with a private method [closed]

Try / catch with a private method [closed] I am trying to call a method that is private inherited from the super class (I KNOW THAT YOU CAN NOT CALL IT IN MAIN BECAUSE IT IS PRIVATE) However, I am trying to use a try catch statement that keeps running my program and give me an exception saying "This method cannot be Called because it is private" (EXAMPLE) this is what I have on my try / catch public int num1 = 3; try { superClass.methodOne(num1); } catch(Exception e) { System.out.printf("%s","ERROR: methodOne cannot be executed! IT IS PRIVATE"); } This is the error that it gives me! error: methodOne(int) has private access Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the que...

What is exception wrapping in Java?

What is exception wrapping in Java? What is Exception wrapping in Java? How is it useful in exception handling? How it differs from exception propagation? Did you even Google this? – tnw Mar 10 '15 at 19:53 @tnw is it duplicate? if it is flag it, otherwise it is good to ask even trivial questions – Muhammad Ramahy Dec 19 '16 at 13:38 4 Answers 4 Exception wrapping is when you catch an exception, wrap it in a different exception and throw that exception. Exception wrapping Here is an example: try{ dao.readPerson(); } catch (SQLException sqlException) { throw new MyException("er...

I'm getting an IndentationError. How do I fix it?

Image
I'm getting an IndentationError. How do I fix it? I have a Python script: if True: if False: print('foo') print('bar') However, when I attempt to run my script, Python raises an IndentationError : IndentationError File "script.py", line 4 print('bar') ^ IndentationError: unindent does not match any outer indentation level I kept playing around with my program, and I was also able to produce three other errors: IndentationError: unexpected indent IndentationError: expected an indented block TabError: inconsistent use of tabs and spaces in indentation What do these errors mean? What am I doing wrong? How can I fix my code? If anyone raises a fuss over this...just post a question on Meta Stack Overflow about it. That's the best place to handle discussion on whether or not this question is appropriate, and even if it'd be suitable as a dupe target at all. – Ma...