In Python, there is this useful exception handling code:
try:
# Code that could raise an exception
except Exception:
# Exception handling
else:
# Code to execute if the try block DID NOT fail
I think it's useful to be able to separate the code that could raise and exception from your normal code. In Python, this was possib...
If I do the following:
$SAFE = 1
begin
load(untrusted_file, true)
rescue Exception => exc
logger.info "Exception handled(#{exc.inspect})!\n #{[email protected]("\n")}"
end
I get a load_without_new_constant_marking exception(removing $SAFE=1 solves it). Why am I getting this exception? Nothing in the untrusted code(contrary to the nam...
I am currently using two catch blocks after a try block. The first catches SqlExceptions, the second Exceptions.
If the SqlException does not have a specific message, I want it to be handled by the general catch block. Is there any way I can pass the exception from the first catch block to the second, or do I have to duplicate the code?
...
I'm working on the back-end of my website and I'm wondering how far I should be going to test for errors and throwing exceptions accordingly? Testing in the sense of improper usage of methods and functions. Not errors under correct usage.
My biggest concern is code bloat and uglying it up with a bunch of if/elses, type checks, and other...
i need to identify who raise an exception to handle better str error, is there a way ?
look at my example:
try:
os.mkdir('/valid_created_dir')
os.listdir('/invalid_path')
except OSError, msg:
# here i want i way to identify who raise the exception
if is_mkdir_who_raise_an_exception:
do some things
if is_listdir_w...
I have a simple parent/child tables. Contract is the parent table. Each contract can have multiple units.
Here is my C# class definitions (simplified):
public class Contract : EntityWithIntID
{
public virtual string ContractNum { get; set; }
public virtual IList<Unit> Units { get; protected set; }
public virtual int N...
Hi,
Given two app domain :
in the first, Library1 and CommonLibrary are loaded. In the second Library2 and CommonLibrary are loaded.
Library2 defines a Library2Exception that inherit from CommonException (defined in CommonLibrary).
When I call, in the first AppDomain, a method on a MarshallByRef of the second AppDomain that throws a Li...
Hi
When I am running a Java class in Eclipse using JAVA/JDK 1.4 its working fine but the same is throwing the following error in JDK 1.3. This is not around version mismatch but something else if you would see the following exception thrown.
[05/03/10 14:51:46:787 IST] 31cf31cf SystemOut O 2010.03.05 14:51:46.787 com.ibm.commerce.c...
I'm currently experiencing a LazyInitException with a page containing code like the following:
<h:form>
<ui:repeat value="#{searchBean.storiesByTag}" var="iStory">
<ui:repeat value="{iStory.tags}"var="iTag">
<!-- Lazy init exception here -->
#{iTag.content}
</ui:repeat>
</ui:repeat>
</h:form>
storiesByTag() is a bean method that...
Is it possible for a process to catch an unhandled exception of another process on the system?
If possible, under which circumstances is it possible? Is it for instance possible if the second process is not started by the first?
I am mainly looking for an answer regarding native c++.
...
I am trying to run a C#/ASP.NET program from VS 2008, but when I do I get the following exception:
System.Security.SecurityException was unhandled
Message="Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
...
Consider the following code:
class A
{
public:
virtual void f() throw ( int ) { }
};
class B: public A
{
public:
void f() throw ( int, double ) { }
};
When compiled, it says that derived class B has a looser throw specifier compared to A. What is the importance of this? If we try to exchange their exception specification, su...
Lets say have this immutable record type:
public class Record
{
public Record(int x, int y) {
Validator.ValidateX(x);
Validator.ValidateY(y);
X=x;
Y=y;
}
public final int X;
public final int Y;
public static class Validator {
public void ValidateX(int x) { if(x < 0) { throw n...
I could have sworn that I've used NUnit's Assert.Throws to determine whether or not a particular exception gets thrown from a method, but my memory has failed me before. I read this post here on SO, but it didn't answer my question, as I know the correct syntax, and I don't want to do anything with the exception that gets returned (I do...
I'm working on a C# windows program with Visual Studio 2008. Usually, I work from school, directly on my usb drive. But when I copy the folder on my hard drive at home, an sql exception is unhandled whenever I try to write to the database. it is unhandled at the conn.Open(); line. here's the exception unhandled
Database 'L:\system\pr...
Hi! As a beginner in Ocaml, I have this current working code:
...
let ch_in = open_in input_file in
try
proc_lines ch_in
with End_of_file -> close_in ch_in;;
Now I would like to add error handling for non-existing input files, I wrote this:
let ch_in = try Some (open_in input_file) with _ -> None in
match ch_in with
| Some x -> t...
I was working on a public comments part of an application on Friday when I got a stack overflow error, which confused me so I thought I'd ask for help. And searching the web using the expression 'stack overflow' is a bit self-defeating!
I wanted to do an HtmlEncode on the set statement of the field in the class, before sending an insta...
I keep getting an expected identifier error at this line in my code =/
$.fn.myPlugin = $.myPlugin;
any idea why this might be happening?
...
We have following code:
try {
// some code throwing MyException
} catch (MyException ex) {
// [1]
// no (re)throw here
} catch (Exception ex) {
if (ex is MyException) {
// [2]
}
}
If we run the code without a debugger attached, everything runs fine. However, IF we debug the code, we don't get to point [1] b...
Hi!
I am using php4Delphi in Delphi.
In my PHP script I`m using the function:
$ret = @socket_recv_from(....);
In a normal PHP script ran by either PHP itselfs or Apache this would not give out a warning when the @ operator is present.
But with my application it does anyways...
I am using PHP version 5.3 and newest release of php4De...