exception

Python can't catch overridden NameError

血红的双手。 提交于 2020-01-04 04:26:05
问题 How can you explain this: This code is supposed to override the NameError and then catch it. OldNameError = NameError class NameError(OldNameError): pass try: ccc except NameError as e: print "hi" Does not print "hi". Instead, the output is: Traceback (most recent call last): File "try.py", line 6, in <module> ccc NameError: name 'ccc' is not defined But this code: OldNameError = NameError class NameError(OldNameError): pass try: raise NameError("oo") except NameError: print "hi" Gives the

Invalid group name: Group names must begin with a word character

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-04 03:52:11
问题 I received the following exception when I was using the Regex class with the regular expression: (?'named a'asdf) System.ArgumentException: parsing \"(?'named a'asdf)\" - Invalid group name: Group names must begin with a word character. What is the problem with my regular expression? 回答1: The problem is the space in the name of the capture. Remove the space and it works fine. From the MSDN documentation: "The string used for name must not contain any punctuation and cannot begin with a number

How to fix error “closing unused connection”

痴心易碎 提交于 2020-01-04 02:58:48
问题 To read in the first 5 columns of Test.csv I may go: x <- matrix(scan(pipe(paste0("cut -f1,2,3,4,5 -d, ","/home/test/Test.csv")),skip=1,sep=","),ncol=5) Then if I read it using a normal method: y <- read.csv("/home/test/Test.csv") I get the error message: Warning message: closing unused connection 3 (cut -f1,2,3,4,5 -d, /home/test/Test.csv) Is this error message a problem, and if so how do I remedy it? 回答1: I cannot replicate the warning on my system. However, you could try closing the

Catch the same exception twice

情到浓时终转凉″ 提交于 2020-01-04 02:22:46
问题 I have the following: public void method(){ try { methodThrowingIllegalArgumentException(); return; } catch (IllegalArgumentException e) { anotherMethodThrowingIllegalArgumentException(); return; } catch (IllegalArgumentException eee){ //1 //do some return; } catch (SomeAnotherException ee) { return; } } Java does not allow us to catch the exception twice, so we got compile-rime error at //1 . But I need to do exactly what I try to do: try the methodThrowingIllegalArgumentException() method

Can not cast IMAPInputStream to Multipart

。_饼干妹妹 提交于 2020-01-04 02:04:49
问题 In Java project, I can receive mails from gmail server. But I want to receive the package part of body. And in this code sample my last message(messages.length - 1) is multipart/mixed. Debug is pass on the if block but it fall into the catch block and gave me this message: Exception in thread "main" java.lang.ClassCastException: com.sun.mail.imap.IMAPInputStream cannot be cast to javax.mail.Multipart How can I handle on this issue? Message[] messages = folder.getMessages(); ArrayList<String>

exception: boost::archive::archive_exception at memory location

↘锁芯ラ 提交于 2020-01-03 19:40:42
问题 When I try to deserialize binary data I get this: exception: boost::archive::archive_exception at memory location write: std::ofstream ofs(savePath); boost::archive::binary_oarchive out_arch(ofs); out_arch << mData; ofs.close(); read: std::ifstream ifs(loadPath); boost::archive::binary_iarchive in_arch(ifs); in_arch >> _mData; When i use text_iarchive \text_oarchive work fine. Serialized data structure mData is ColorMatrix<std::map<int, float>> mData; #include <algorithm> #include <memory>

Android:Use ButterKnife in Activity extending from another activity

假装没事ソ 提交于 2020-01-03 19:15:14
问题 I wanted navigation drawer in all my activities.So i used a BaseActivity for Navigation drawer and extended other activities from base activity.Base activity has Navigation drawers. Dashboard activity is extending base activity but it raises exception when i try to use butterknife to bind views saying java.lang.IllegalStateException: Required view 'dashboard_frameLayout' with ID 2131558517 for field 'frameLayout' was not found. here are the relevant files BaseActivity.java public class

Crash dump with unknown origin

时光毁灭记忆、已成空白 提交于 2020-01-03 19:01:27
问题 I have my application crashing with following CallStack on the error (from WinDbg): ntdll!ZwWaitForMultipleObjects+0xa KERNELBASE!WaitForMultipleObjectsEx+0xe8 kernel32!WaitForMultipleObjectsExImplementation+0xb3 clr!WaitForMultipleObjectsEx_SO_TOLERANT+0x91 clr!Thread::DoAppropriateAptStateWait+0x56 clr!Thread::DoAppropriateWaitWorker+0x1b1 clr!Thread::DoAppropriateWait+0x73 clr!CLREvent::WaitEx+0xc1 clr!CLREventWaitWithTry+0x5c clr! ?? ::FNODOBFM::`string'+0x6286a clr

Recover stdin from eof in C

牧云@^-^@ 提交于 2020-01-03 17:26:34
问题 I am using the C code below to read user input from a terminal. If the user inputs EOF, e.g. by pressing ^C, stdin is closed and subsequent attempts to read from it, e.g. via getchar() or scanf(), will cause an exception. Is there anything I can do in C to "recover" my program, in the sense that if some user accidently inputs EOF, this will be ignored, so I can read from stdin again? #include <stdio.h> int main(void) { int res_getchar=getchar(); getchar(); return 0; } 回答1: Using ungetc() to

Can I make Visual Studio break on a user-defined C++ exception?

徘徊边缘 提交于 2020-01-03 17:16:11
问题 I have an application that throws many (handled) exceptions. There is one type of exception in particular that I would like to break on. Is it possible to make the debugger break on a specific user-defined exception? I don't see why this wouldn't be possible, since it does know the type of the exception that was thrown. I can work around this by setting a breakpoint in the exception's constructor, but it would be nice to know how to do it the 'correct' way. 回答1: If you go to the Debug menu