exception-handling

How to re-raise pl/sql exception in exception handling block?

半城伤御伤魂 提交于 2020-01-02 00:13:31
问题 I have the following procedure which is used by some applications: procedure p1 is begin bla bla bla; end; But there is no exception handling block. So applications were written according this feature. Now I need to log errors in p1. But it shouldn't affect applications that use this procedure. Something like this: procedure p1 is begin bla bla bla; exception when others then log_error(sqlcode, sqlerrm); raise_new_exception (sqlcode, sqlerrm); end; In case of raise_application_error first

Capture exceptions with a different handler for applications REST

陌路散爱 提交于 2020-01-01 14:10:34
问题 The problem I'm building a small application with Silex . It's divided between a REST application and a website. (two controllers, same app). The website has installed its own custom error handler, which returns a user friendly html page. The problem is that in the part dedicated REST application, I should somehow handle exceptions to return type [json] and content different from the error handler's custom website. With Symfony2 This argument can also be applied to Symfony2, I would like also

How to catch an exception and respond with a status code in .NET Core

倾然丶 夕夏残阳落幕 提交于 2020-01-01 12:18:07
问题 I am running a .Net Core Web API project. I have a startup file (below). In the Startup.ConfigureServices(...) method, I add a factory method that creates an instance of IFoo. I want to catch any exceptions that the IFooFactory throws and return a better error message with a status code. At the moment I getting a 500 Error with the exception Message. Can anyone help? public interface IFooFactory { IFoo Create(); } public class FooFactory : IFooFactory { IFoo Create() { throw new Exception(

Catching exceptions in Java

混江龙づ霸主 提交于 2020-01-01 12:15:14
问题 There are certain predefined exceptions in Java, which, if thrown, report that something serious has happened and you'd better improve your code, than catching them in a catch block (if I have understood it correctly). But still I find many programs in which I have the following: } catch (IOException e) { ... } catch (FileNotFoundException e) { .... } and I thought that IOException and FileNotFoundException are exactly such kind of exceptions, which we shouldn't catch in a catch block. Why

TPL Break on unhandled exceptions

心已入冬 提交于 2020-01-01 12:07:15
问题 I am using async await as well as Task.Factory.StartNew in my application but one thing that i noticed changed is that visual studio is no more breaking when an unhandled exception occured Here is what i mean by before using await but after i turn a method into a Task and use await It is only captured in the output area in visual studio... BTW : It is very strange for me as i am new to .Net4.5 please excuse me if failed to illustrate what i need specifically but again what i want to know is

Best Practice for Try Catch Error Handling

大兔子大兔子 提交于 2020-01-01 12:06:37
问题 I'm trying to avoid returning an incorrect value when in the catch but I'm having trouble finding a better solution than this: private SecurityLevel ApiGetSecurityLevel() { try { return _BioidInstance.GetSecurityLevel(); } catch { return SecurityLevel.High; } } Is there a better way of doing this so I don't return incorrect values? I can't change the SecurityLevel enum. 回答1: Do not catch the exception. Allow the exception to "bubble-up" to force the caller/callers to handle setting the

What are the difference in usage between Either and Except in Haskell?

▼魔方 西西 提交于 2020-01-01 11:58:08
问题 I have a class that can be created from several arguments in Haskell which requires some complex validation of those arguments. Currently I have something like makeAThingExcept :: String -> String -> ... String -> Except ThingError AThing makeAThingExcept s1 s2 ... = do unless (s1CheckPasses s1) (throwError (BadS1 s1)) ... data ThingError = BadS1 String ... instance Show ThingError where show (BadS1 s) = "Bad S1: " ++ s makeAThing :: String -> String -> ... String -> AThing makeAThing s1 s2 .

c++ exception in destructor

强颜欢笑 提交于 2020-01-01 11:12:14
问题 From other threads, I know we should not throw exception in destructor! But for below example, it really works. Does that means we can only throw exception in one instance's destructor? how should we understand this code sample! #include <iostream> using namespace std; class A { public: ~A() { try { printf("exception in A start\n"); throw 30; printf("exception in A end\n"); }catch(int e) { printf("catch in A %d\n",e); } } }; class B{ public: ~B() { printf("exception in B start\n"); throw 20;

c++ exception in destructor

末鹿安然 提交于 2020-01-01 11:11:09
问题 From other threads, I know we should not throw exception in destructor! But for below example, it really works. Does that means we can only throw exception in one instance's destructor? how should we understand this code sample! #include <iostream> using namespace std; class A { public: ~A() { try { printf("exception in A start\n"); throw 30; printf("exception in A end\n"); }catch(int e) { printf("catch in A %d\n",e); } } }; class B{ public: ~B() { printf("exception in B start\n"); throw 20;

Using bool (return Type) to handle exceptions or pass exception to client?

喜欢而已 提交于 2020-01-01 10:51:29
问题 I am trying to find out the best way of handling exceptions, I have a number of layers to my application and started to use a return type of BOOL i.e. if it fails then return False and if it succeeds return True.. This works great in methods like SaveMyRecord(somerecord); as i am passing in values and don't require anything returned so i can use the return type of bool to indicate if it succeeds or not. But then it got me thinking that things like GetMyRecord() actually returns type of