exception

Raising an exception on updating a 'constant' attribute in python

对着背影说爱祢 提交于 2019-12-30 11:06:13
问题 As python does not have concept of constants, would it be possible to raise an exception if an 'constant' attribute is updated? How? class MyClass(): CLASS_CONSTANT = 'This is a constant' var = 'This is a not a constant, can be updated' #this should raise an exception MyClass.CLASS_CONSTANT = 'No, this cannot be updated, will raise an exception' #this should not raise an exception MyClass.var = 'updating this is fine' #this also should raise an exception MyClass().CLASS_CONSTANT = 'No, this

How to avoid nested AggregateException when using Task.ContinueWith?

走远了吗. 提交于 2019-12-30 11:03:44
问题 I have an async method in a .NET 4.5 C# component: public async Task<T> GetResultAsync() { return PerformOperationAsync(); } If PerformOperationAsync throws an exception, then I can catch an AggregateException on a client side, unwrap it and get the original exception thrown. However, if I have slightly more complicated code: public async Task<T> GetResultAsync() { return PerformOperationAsync().ContinueWith(x => { var result = x.Result; return DoSomethingWithResult(result); },

How to avoid nested AggregateException when using Task.ContinueWith?

巧了我就是萌 提交于 2019-12-30 11:03:36
问题 I have an async method in a .NET 4.5 C# component: public async Task<T> GetResultAsync() { return PerformOperationAsync(); } If PerformOperationAsync throws an exception, then I can catch an AggregateException on a client side, unwrap it and get the original exception thrown. However, if I have slightly more complicated code: public async Task<T> GetResultAsync() { return PerformOperationAsync().ContinueWith(x => { var result = x.Result; return DoSomethingWithResult(result); },

info - unhandled socket.io url

天大地大妈咪最大 提交于 2019-12-30 10:35:30
问题 I working on a socket.io + node project. Just like in this page, http://davidwalsh.name/websocket I am getting "info - unhandled socket.io url" error in socket.io v7. But I dont get this error with v6.17? Do you have any idea with this error? Thanks 回答1: Had the exact issue couple of days back and looks like socket.io had some changes in the API. I have a working demo of socket.io sending and receiving a message - uploaded to https://github.com/parj/node-websocket-demo as a reference

info - unhandled socket.io url

*爱你&永不变心* 提交于 2019-12-30 10:35:03
问题 I working on a socket.io + node project. Just like in this page, http://davidwalsh.name/websocket I am getting "info - unhandled socket.io url" error in socket.io v7. But I dont get this error with v6.17? Do you have any idea with this error? Thanks 回答1: Had the exact issue couple of days back and looks like socket.io had some changes in the API. I have a working demo of socket.io sending and receiving a message - uploaded to https://github.com/parj/node-websocket-demo as a reference

XCode: Exception. How to detect the cause?

不羁的心 提交于 2019-12-30 10:34:33
问题 Xcode 4.6.1 with iOS 6.1. I'm using remote database with StackMob. Application first gives an error and after I click Play a few times, it runs fine and communicates with the server just fine. Not sure how to detect the problem and should it a concern? I have the following exception Break Point setup: The application runs and then stops at the following line: NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"User"

Use of “except Exception” vs. “except … raise” in Python

独自空忆成欢 提交于 2019-12-30 10:06:12
问题 I'm reading some source code which contains a function similar to the following: def dummy_function(): try: g = 1/0 except Exception as e: raise Exception("There is an error: {}".format(e)) As I understand it, all exceptions are derived from the Exception class, so this should catch all errors. Following https://docs.python.org/3/tutorial/errors.html, then, would this not be equivalent to def dummy_function(): try: g = 1/0 except: print "There is an error:" raise I notice that the printed

How can I remove exception “Predefined type 'ValueTuple`2' must be a struct” when debugging?

时光怂恿深爱的人放手 提交于 2019-12-30 09:58:24
问题 I started using the new tuple feature in c# 7.0 but I noticed that neither in the function that returns a tuple nor in its caller is possible to check the variable values in debug mode. Instead an exception is shown: $exception error CS8182: Predefined type 'ValueTuple`2' must be a struct. Is there a way to get rid of that glitch and debug normally? 回答1: It seems a bug that Microsoft has fixed but it will be available in a future update (2017) https://github.com/dotnet/roslyn/pull/16930 回答2:

Can't seem to handle XMLException?

痞子三分冷 提交于 2019-12-30 09:39:08
问题 I have the following code in one of our projects webpages: XmlDocument xDoc = new XmlDocument(); xDoc.Load(File.FullName); //work through each print batch in this queue file try { XmlNodeList nodeList = xDoc.SelectNodes("Reports/PrintBatch"); foreach (XmlNode printBatch in nodeList)//xDoc.SelectNodes("Reports/PrintBatch")) { PrintBatch batch = new PrintBatch(); batch.LoadBatch(printBatch, File.Extension); this.AddBatch(batch); } } catch (XmlException e) { //this report had an error loading!

RestEasy - Unable to find MessageBodyReader?

谁说我不能喝 提交于 2019-12-30 09:22:52
问题 I've written a simple RestEasy client proxy to perform an iTunes search. It looks like this: @Path("/") public interface AppleAppStoreLookupClient { /** * Attempts to lookup an apple app store item by its ID * * @param id * The item ID * @return The app details */ @GET @Path("/lookup") @Produces(value = { "text/javascript" }) public AppleAppDetailsResponse lookupByID(@QueryParam("id") String id); } My JSON model class is simple, as well. In fact, for the first call all I want is the