exception-handling

try is returning Either instead of IO (Either ex a)

旧城冷巷雨未停 提交于 2019-12-24 07:17:19
问题 I'm trying to handle exceptions from my request parser: go bs = case try $ parseRequest reader bs secure of Left ex -> exceptionHandler writer ex Right (request, bs') -> do sendResponse writer =<< app request go bs' But I have an issue when using try : Couldn't match expected type `IO (Either e0 (Request, ByteString))' with actual type `Either t0 t1' In the pattern: Left ex In a case alternative: Left ex -> exceptionHandler writer ex In the expression: case try $ parseRequest reader bs secure

View.java line 18891 android.view.View.onRestoreInstanceState Exception

こ雲淡風輕ζ 提交于 2019-12-24 06:21:07
问题 I am getting some exceptions in crashlytics . but not able find the file or cause of an exception. Also, I am getting different line number every time. I don't have much information I am seeking for the details. From crashlytics I get the device details like : -- Samsung SM-G950F -- Android 8 -- View.java line 18877, View.java line 18891 -- Oppo R7plusf -- Android 5 -- View.java line 13790 --Asus ASUS_X00LD -- Android 8 -- View.java line 17753 View.java line 18891 android.view.View

HttpPostedFile.SaveAs error, rooted path?

送分小仙女□ 提交于 2019-12-24 05:59:29
问题 I have an HttpPostedFile object, when I try saving it via SaveAs I get this exception System.Web.HttpException The SaveAs method is configured to require a rooted path, and the path './tempUpload/4' is not rooted. Why? how do I correct it? 回答1: The path should be an absolute path, not a relative url. Use the Server.MapPath method to get the absolute path from your relative url. 回答2: ASP.NET doesn't like the dot in your path. Try 'tempUpload/4' instead. 回答3: You can use this code for saving a

Why try-catch block cannot handle the exception?

馋奶兔 提交于 2019-12-24 05:55:01
问题 FSDKCam.GetVideoFormatList is a method from external .NET dll. As you see the image, it throws an exception in try-catch block. try { FSDKCam.GetVideoFormatList(ref cameraList[0], out formatList, out count); if (count > 0) cmbCameraList.Items.Add(cam); } catch { } Screenshot: 回答1: In .NET 4, AccessViolationException is not catchable by default. See the legacyCorruptedStateExceptionsPolicy configuration element. They did this because people have try {} catch (Exception) {} throughout their

Exception/MessageBox in Calibur.Micro

北战南征 提交于 2019-12-24 05:54:40
问题 I start learning Caliburn.Micro and I am little confuse of handling with exception/messange box in view model class. I found some blogs about, for example: http://frankmao.com/2010/11/18/handling-messagebox-in-caliburn-micro/ For example some method in view model class which can produce exception. public void MethodWichCanProduceEx(string arg1, string arg2 ) { if(arg1==null) throw new ArgumentNullException("arg1 is null"); if (arg2 == null) throw new ArgumentNullException("arg2 is null"); try

F# exception handling multiple “Tries”

笑着哭i 提交于 2019-12-24 05:34:15
问题 I'm trying to read a bunch of csv files in SQL Server using SQL Bulk Insert and DataContext.ExecuteCommand. (Maybe this isn't the best way to do it, but it does allow me stay in the Type Provider context--as opposed to with SqlBulkCopy I think.) Now the upload is glitchy with intermittent success. Some files read in, some fail with "Data conversion error (truncation)". I think this has to do with the row terminators not always working. When the upload works, it seems to be with the '0x0A'

Determining System.Net.Mail.SmtpClient.Send result

ε祈祈猫儿з 提交于 2019-12-24 05:32:17
问题 I am trying to summarize the outcomes from System.Net.Mail.SmtpClient.Send using an enum. This is so I know whether I should retry sending the email and hopefully prevent duplicate emails being sent. public enum MailSendStatus { None, Sent, ErrorCannotSend, TryAgain, SentMaybe } I have caught all the exceptions from Send and split out the SmtpException.StatusCode s from http://msdn.microsoft.com/en-us/library/system.net.mail.smtpstatuscode(v=vs.80).aspx. Does the breakdown look right? Or is

Handling an exception as a method argument

无人久伴 提交于 2019-12-24 05:24:09
问题 I am looking for a design pattern to handle Exception instances received as method arguments. To put some context into the question, I am using GWT and have various asynchronous handlers that usually come in a form similar to: public interface AsyncCallback<T> { void onFailure(Throwable caught); void onSuccess(T result); } So, the onFailure method receives a Throwable instance that I need to handle. Now, I have a number of exceptions I can receive in this method, for example

python catching NameError when loading module

旧时模样 提交于 2019-12-24 03:26:18
问题 I'm trying to catch any exceptions that happen when you cannot load a module. The current results are that the "except" block does not get executed. import sys def loadModule(module): try: import module except: print """ Cannot load %s For this script you will need: cx_Oracle: http://cx-oracle.sourceforge.net/ pycrypto: https://www.dlitz.net/software/pycrypto/ paramiko: http://www.lag.net/paramiko/ """ % module sys.exit(1) loadModule(cx_Oracle) Error: Traceback (most recent call last): File "

Android Google Analytics Exception logging

社会主义新天地 提交于 2019-12-24 03:22:30
问题 I'm using Google Analytics SDK v4 for Android to record the exceptions. I followed the sample app but I could see no exceptions getting registered in the dashboard. I wrote the code as below /*exception tracking */ // Get tracker. Tracker t2 = ((MyApp) this.getApplication()).getTracker(TrackerName.APP_TRACKER); // Build and send exception. int a = 0; String exceptionStr = ""; try{ int b = a/0; }catch(Exception ex){ exceptionStr = ex.toString(); }finally{ t2.send(new HitBuilders