exception-handling

Java Mail timeout & connectiontimeout handling

和自甴很熟 提交于 2019-12-12 11:03:38
问题 I'm using JavaMail to send email requests to an SMTP server. I would like to set both "mail.smtp.connectiontimeout" and "mail.smtp.timeout" properties within my code. Programmatically, I want to catch both when timeout and/or connectiontimeout operations are reached in Java and handle things accordingly. Handling in the sense, I need to retry the same email once again the next time. How do I handle this in Java/JavaMail? Is it possible to catch & handle this timeout operations? EDIT Also, is

Exceptions lose part of stacktrace in try/catch context

和自甴很熟 提交于 2019-12-12 10:49:30
问题 I have two examples. In the first case, debugger catches the unhandled exception: static void Main(string[] args) { Exec(); } static void Exec() { throw new Exception(); } And the exception has full stacktrace: at ConsoleApplication28.Program.Exec() at ConsoleApplication28.Program.Main(String[] args) at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft

Is there a standard way for perl to behave when it runs out of memory?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 10:48:08
问题 Is there a standard(ish) way for a Perl interpreter (aka "perl") to behave when it runs out of memory? Is it documented/specced-out in any way? Coded in some uniform way? I'm especially interested in any standards which are expressed as covenant to Perl code being run - e.g., will die be called? Will END block be executed? Etc... I'm fine with both an "theoretical" answer (e.g. some sort of generic "this is what perl code ought to do in general on out-of-memory" mission statement document

Throwing Exception with inner SecurityException only displays inner exception in ASP.NET MVC

坚强是说给别人听的谎言 提交于 2019-12-12 10:45:15
问题 If I add the following line to an ASP.NET MVC action method throw new Exception("outer", new SecurityException("inner")); the error that is actually displayed on the yellow screen of death is the inner SecurityException with absolutely no mention of the outer exception. SecurityException Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the

Correct Exception to throw when a duplicate key insertion is attempted?

五迷三道 提交于 2019-12-12 10:42:52
问题 Repeatedly I see comments about avoiding throwing generic RuntimeException and I am trying to follow that guideline. I have a class that aggregates a SortedMap with a property setting to allow or disallow duplicate keys. I am trying to figure out what Exception I should throw when duplicate keys are disallowed and an attempt is made to add one. I checked the Java docs for the Exception class and none of the known direct descendants seemed suitable. Do I just go ahead and create my own

Exception Handling Strategy with Spring/JPA/JSF

本秂侑毒 提交于 2019-12-12 10:38:36
问题 We are using JSF, Spring and JPA in our application. We are trying to simplify our Exception Handling strategy for our project. Our application architecture is like below: UI(JSF) --> Managed Beans --> Service --> DAO We are using Exception Translation bean post processor for DAO layer. This is configured in Spring Application Context file. <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /> Where Spring wraps all database exceptions to 'org

TimeOutException when use link_text with explicit wait in selenium webdriver with python

99封情书 提交于 2019-12-12 10:19:11
问题 I am using selenium webdriver with python. I want to use explicit wait for locating element on the basis of the links they are pointing to. For achieving this, I am using element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, 'dashboard'))) Here is the html code for that: <li class="headerLink" name="dashboard"><a href="http://www.xy.com/dashboard" class="touch">Dashboard</a></li> Everytime I run this query, I get TimeOutException but if I use By.ID ,

Ignore user input outside of what's to be chosen from

你说的曾经没有我的故事 提交于 2019-12-12 10:17:12
问题 I have a program in which the user must make a selection by entering a number 1-5. How would I handle any errors that might arise from them entering in a digit outside of those bounds or even a character? Edit: Sorry I forgot to mention this would be in C++ 回答1: Be careful with this. The following will produce an infinite loop if the user enters a letter: int main(int argc, char* argv[]) { int i=0; do { std::cout << "Input a number, 1-5: "; std::cin >> i; } while (i <1 || i > 5); return 0; }

Inherit Exception class to log all subsequent occurrences of exception

两盒软妹~` 提交于 2019-12-12 09:58:02
问题 If I want to log all occurrences of exceptions throughout my application so far, should I inherit Exception class and throw all exception of that class, whose constructor will log the error details.. or any idea or suggestion??? 回答1: Depending on the type of Application (ASP.NET/Console etc) there are different approaches to take. For Windows Forms Applications this is the way to go: - namespace YourNamespace { static class Program { [STAThread] static void Main() { AppDomain.CurrentDomain

How to avoid many try catch blocks in java

我的未来我决定 提交于 2019-12-12 09:38:34
问题 I'm very new to java and the idea of try catch blocks to handle exceptions. This roughly what I'm ending up with, and there simply has to be a better way: try { JSONObject jsonObject = new JSONObject(jsonString); int aCount = jsonObject.getInt("acount"); String devTok = jsonObject.getString("dt"); String qURL = jsonObject.getString("qu"); try { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Key qKey = KeyFactory.createKey("qu", qURL); int dsACount = (Integer)