exception-handling

Python HTTP Exception Handling

有些话、适合烂在心里 提交于 2019-12-06 09:53:29
I'm running a program that downloads files from a web sit. I've introduced one exception handling urllib.error.HTTPError, but now I'm getting from time to time additional errors that I'm not sure how to capture: http.client.IncompleteRead. Do I just add the following to the code at the bottom? except http.client.IncompleteRead: How many exceptions do I have to add to make sure the program doesn't stop? And do I have to add them all in the same Except statement or in several Except statements. try: # Open a file object for the webpage f = urllib.request.urlopen(imageURL) # Open the local file

yii2: Proper way to throw new exception

女生的网名这么多〃 提交于 2019-12-06 09:21:38
Just for testing I have added this code in my model while setting the debug = true and false. if($packagedays < 1) { throw new \yii\base\Exception( "package days cannot be less than 1" ); } Now when Yii debug is true: I am getting Exception – yii\base\Exception package days cannot be less than 1 But when I am setting the debug to false I am getting Exception An internal server error occurred. The above error occurred while the Web server was processing your request. What I want is to replace the An internal server error occurred. with package days cannot be less than 1 when debug=false What I

How to catch exception on RollBack

十年热恋 提交于 2019-12-06 09:11:56
问题 What is the best way to implement error handling for a SqlTransaction RollBack that already exists within a catch clause? My code is roughly like this: using (SqlConnection objSqlConn = new SqlConnection(connStr)) { objSqlConn.Open(); using (SqlTransaction objSqlTrans = objSqlConn.BeginTransaction()) { try { // code // more code // and more code } catch (Exception ex) { // What happens if RollBack() has an exception? objSqlTrans.Rollback(); throw ex; } } } I believe that my application had an

Extending the std::exception class : program won't execute the appropriate catch handler

筅森魡賤 提交于 2019-12-06 09:06:34
问题 I have derived a class from std::exception: class exc : public std::exception { public: exc(const text::_char *) throw(); exc(const exc &) throw(); virtual ~exc() throw(); text::_char *m_what; }; I have two wrapper functions to throw my exception type: PS: dbg_out refers to std::cout. text is a descendant of std::basic_string<< char >>. void throw_exception(const text::_char *p_format, ...) { va_list l_list; text l_message; va_start(l_list, p_format); l_message.format_va(p_format, l_list); va

Exceptions in Web Services

你离开我真会死。 提交于 2019-12-06 08:57:42
My group is developing a service-based (.NET WCF) application and we're trying to decide how to handle exceptions in our internal services. Should we throw exceptions? Return exceptions serialized as XML? Just return an error code? Keep in mind that the user will never see these exceptions, it's only for other parts of the application. FlySwat WCF uses SoapFaults as its native way of transmitting exceptions from either the service to the client, or the client to the service. You can declare a custom SOAP fault using the FaultContract attribute in your contract interface: For example:

Catching PDOException in lower layer and re-throwing as different exception to upper layer

喜夏-厌秋 提交于 2019-12-06 08:47:57
问题 Hello I am writing small PHP framework using PDO library. So at this moment I am facing with the exception catching problem. I want to catch thrown PDOException in lower layer and re-throw it as different exception object and bubble it up in such way to upper layer, hiding sensitive error information from users and displaying abstract useful messages for site admins and etc. In the example code (Mssql.class.php) I am trying to catch exception and re-throw as DBIException object when the

Spring Integration - writing to a error queue when Exception happended in a Service Activator component

我的未来我决定 提交于 2019-12-06 08:44:40
问题 I'm starting to use Spring integration and I don't know how to resolve this situation if it's possible. I would like to 'catch' automatically every Exception who could happend in the service activators of my application and send this errors to a dedicated queue. Gateway is not a solution because I need some custom code so I have to use service activator elements if I have correctly understood the principle. I thought that something like would be ok: <jms:outbound-channel-adapter channel=

Does a legitmate epilog need to include a dummy rsp adjustment even if not otherwise necessary?

余生颓废 提交于 2019-12-06 08:26:58
The x86-64 Windows ABI has the concept of a legitimate epilog , which is a special type of function epilog that can be simulated during exception handling in order to restore the callers context 1 as described here : If the RIP is within an epilog [when an exception occurs], then control is leaving the function, ... and the effects of the epilog must be continued to compute the context of the caller function. To determine if the RIP is within an epilog, the code stream from RIP on is examined. If that code stream can be matched to the trailing portion of a legitimate epilog, then it is in an

Getting Cross-thread operation not valid in MDIParent [duplicate]

送分小仙女□ 提交于 2019-12-06 08:23:21
This question already has answers here : Closed 6 years ago . Possible Duplicate: Cross-thread operation not valid I am trying to close the base of a form from another thread. I am getting the following error. System.InvalidOperationException: Cross-thread operation not valid: Control 'MDIParent' accessed from a thread other than the thread it was created on. for the below line: MDIParent.MDIParentRef.BaseClose(); You need to perform the operation on the UI Thread: if (InvokeRequired) Invoke(new Action(MDIParent.MDIParentRef.BaseClose)); else MDIParent.MDIParentRef.BaseClose(); 来源: https:/

Catch WM_COPYDATA from Delphi component

六眼飞鱼酱① 提交于 2019-12-06 08:22:43
问题 I'm trying to write a component, to send string messages between applications by WM_COPYDATA. I'd like trap the WM_COPYDATA, but this doesn't work: TMyMessage = class(TComponent) private { Private declarations } … protected { Protected declarations } … procedure WMCopyData(var Msg : TMessage); message WM_COPYDATA; … end; Searching Google a lot, found some reference using wndproc. I tried it, but it isn't working either. TMyMessage = class(TComponent) … protected { Protected declarations } …