FAQ Database Discussion Community


C++ Have lone executable log exceptions?

c++,debugging,exception,logging
I'm currently in a beta testing phase of my C++ Server. I'm sending it out to users to stress test it to see if an exceptions show up. However, since the .exe is a standalone, how do I make it so it automatically creates a dump or a log of...

java.lang.ArrayStoreException with new JPanel

java,swing,exception,jpanel
I have a problem: public static JPanel regNewBodyPart(int i, int x, int y){ //System.out.println(i); body[i] = new SnakeBlock(); JPanel bp = body[i]; //bp.setBackground(Color.GREEN); bp.setBounds(x, y, 20, 20); bp.setVisible(true); registeredBodyParts++; return(bp); } Throws an java.lang.ArrayStoreException, when I change body[i] = new SnakeBlock(); to body[i] = new Block(); does not. I dont...

Java Error unreported exception IOException; must be caught or declared to be thrown

java,exception,ping
I am making a code in which this program sends a ping request to the other machine. import java.io.*; class NetworkPing { private static boolean pingIP(String host) throws IOException, InterruptedException { boolean isWindows = System.getProperty("os.name").toLowerCase().contains("win"); ProcessBuilder processBuilder = new ProcessBuilder("ping", isWindows? "-n" : "-c", "1", host); Process proc = processBuilder.start();...

How to catch an exception and continue without stopping

python,exception
I have the following code import msgpack def deserialize(data) return msgpack.loads(data) for data in stream: print deserialize(data) Now, the issue is that some data is (maybe) corrupted.. and I am seeing this error: UnicodeDecodeError: 'utf8' codec can't decode byte 0xcc in position 0: invalid continuation byte Why am I getting...

throws x extends Exception method signature

java,exception,generics
Reading the JavaDoc of Optional, I bumped in a weird method signature; I never saw in my life: public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X extends Throwable At first glance, I wondered how the generic exception <X extends Throwable> is even possible, since you can't do...

How to print the first line from a traceback stack

python,exception,stack-trace,traceback
Suppose I am given the following traceback: Traceback (most recent call last): File "<wingdb_compile>", line 3, in <module> File "C:\Python34\lib\ftplib.py", line 419, in login resp = self.sendcmd('PASS ' + passwd) File "C:\Python34\lib\ftplib.py", line 272, in sendcmd return self.getresp() File "C:\Python34\lib\ftplib.py", line 245, in getresp raise error_perm(resp) ftplib.error_perm: 530 Login incorrect....

RoundingMode.UNNECESSARY throws exception

java,exception,number-formatting,bigdecimal
I wrote this to test BigDecimal in action but found that RoundingMode.UNNECESSARY threw an exception. Can anyone explain why? public class TestRounding2 { public static void main(String args[]) { Locale swedish = new Locale("sv", "SE"); BigDecimal pp; //declare variable pp=pounds pence NumberFormat swedishFormat = NumberFormat.getCurrencyInstance(swedish); Scanner scan = new Scanner(System.in);...

Replace backslash in string

java,regex,string,exception,replace
I have a String in which I am trying to replace the number enclosed by two backslashes. For example: \10\ , I am trying to replace that with 10. I am currently using this regex to do that: String texter = texthb.replaceAll("\\.+\\", "\\"+String.valueOf(pertotal + initper)+"\\"); This line is giving the...

Exception in async task gets intercepted in Visual Studio

c#,visual-studio,exception,asynchronous
I want to run several tasks, some of which would complete async'ly, and then wait for all of them to complete. As the tasks may throw exceptions, I want to catch and log them. sample code for that: static async Task doit(int x) { try { Console.WriteLine("{0} {1} start", x,...

Destructor throwing an exception

c++,exception
I'm reading Scott Meyerses C++ and now I'm at the destructor throwing exceptions section. Here is what is he said: When the vector v is destroyed, it is responsible for destroying all the Widgets it contains. Suppose v has ten Widgets in it, and during destruction of the first one,...

What is the purpose of RAISE_APPLICATION_ERROR?

oracle,exception,plsql
I understand that RAISE_APPLICATION_ERROR associates a message error which only has a meaning to the user. But can't the user just write a similar exception the following way? DECLARE e_negative EXCEPTION; BEGIN IF v_sid < 0 THEN RAISE e_negative; ... EXCEPTION WHEN e_negative THEN DBMS_OUTPUT.PUT_LINE ('An id cannot be negative');...

May I modify the value of an exception inside a std::exception_ptr?

c++,exception,c++11,exception-handling
If I have a exception stored inside std::exception_ptr. I rethrow the exception using std::rethrow_exception, access it using catch(MyException&) and then I modify the value. If I throw the same exception again, should I observe the modification I made? The following code demonstrate my idea: #include <exception> #include <iostream> struct MyException...

Throwable constructors

java,exception,constructor,throwable
The 4 types of Throwable constructors are :- Throwable() : Constructs a new throwable with null as its detail message. Throwable(String message) : Constructs a new throwable with the specified detail message. Throwable(String message, Throwable cause) : Constructs a new throwable with the specified detail message and cause. Throwable(Throwable cause)...

How can I extract ALL the information of the JavaScript native exception?

javascript,exception,exception-handling
Well, as JavaScript is executed in the client-side, I can't control a bunch of environment variables and, at some point, my app will probably throw an exception. What I want to do is to get this exception and make my app fail gracefully and show the maximum information as possible...

Exception casting valid JSON with Java

java,json,exception
I have a JSON string: { "_id": -1, "create_date": 0, "update_date": 0, "description": "test", "active": true } In Java, I try to parse it using org.json.simple.parser.JSONParser : JSONParser jsonParser = new JSONParser(); org.json.simple.JSONObject jsonObject = (org.json.simple.JSONObject) jsonParser.parse(phoneJSON); I try to retrieve the _id field value: String s_id = ((String) jsonObject.get("_id"));...

Add user to LDAP using JAVA. Naming.InvalidNameException: Invalid Name

java,exception,ldap,openldap
I am practicing in Java, adding a user to LDAP(v3, running on my Virtual machine). Userdetails and attributes are obtained from postgres database running locally. This is my code (may not be a good approach): public class LDAPConnector { static final String DOMAIN_URL = "ldaps://10.10.10.180:636/"; static final String ADMIN_NAME =...

Handle unexpected exceptions that silently kill a thread

java,exception,exception-handling
I've a thread that sometimes just dies silently and I want to surround the operation with a try/catch block to find out what is going on without killing the thread. I initially surrounded the operations within run with a try / catch (Exception e) block but the concern was that...

Android Build failed at ':app:dexDebug' with exception ( library and app project )

android,exception,gradle,build
I am using some third party libraries in my library project. The following is my library project build.gradle apply plugin: 'com.android.library' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { minSdkVersion 14 targetSdkVersion 21 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } //dexOptions...

Java Ignoring an Exception and Continuing Loop

java,exception
I have a program where it checks if a given URL is real multiple times, each with different URLs. I have a for loop set up: for (int i=0;i<100;i++) { URL url=findWebsite(); System.out.println(readURL(url)); } But when it encounters a URL that does not exist, it just throws a Runtime error...

C# console application - Unhandled exception while finding the Available and free Ram space.Getting exact answer in windows forms application

c#,exception,memory,ram,unhandled
Unhandled exception while finding the Available and free Ram space.Getting exact answer in windows forms application while displaying details in a textbox but getting exception in console application.I've added all possible references..Not showing any error during compile time... using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq;...

Why is eclipse complaining when I try to close BufferedReader in finally block?

java,eclipse,exception,bufferedreader,try-catch-finally
Here is my code: public static String readFile() { BufferedReader br = null; String line; String dump=""; try { br = new BufferedReader(new FileReader("dbDumpTest.txt")); } catch (FileNotFoundException fnfex) { System.out.println(fnfex.getMessage()); System.exit(0); } try { while( (line = br.readLine()) != null) { dump += line + "\r\n"; } } catch (IOException...

std::ostream to QString?

c++,qt,exception
Is there a way to convert an std::ostream to a QString? Allow me to expand in case it is useful: I am writing a program in C++/Qt and I used to (not) deal with / debug exceptions by just using std::cout, as in for example: std::cout << "Error in void...

_controlfp does not prevent DivideByZeroException

c#,exception,dllimport,divide-by-zero,floating-point-exceptions
I wrote the following lines in C# using System; using System.Runtime.InteropServices; namespace ConsoleApplication1 { class Program { [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] extern static uint _controlfp(uint newcw, uint mask); const uint _MCW_EM = 0x0008001f; public const uint EM_INVALID = 0x00000010; public const uint EM_DENORMAL = 0x00080000; public const uint EM_ZERODIVIDE =...

Error: Integers added together in successive uses of scanner class

java,exception,java.util.scanner
I'm doing exercises related to handling exceptions. While using the Scanner class and following exercises to check for InputMismatchExceptions, I got the following results from the following code. static Scanner sc = new Scanner(System.in); public static void main(String[] args){ System.out.print("Enter an integer: "); int a = getInt(); System.out.print("Enter a second...

Java - How to keep running on exception

java,exception,exception-handling
This question seems pretty simple. How do I keep running my application on an exception. For instance how would I go about doing this. Server application tries to run on port 1234, but it's not available. Normally it would just crash. But how can I make it keep running and...

Python exception for HTTP response codes

python,http,exception
I'd like to raise a Python-standard exception when an HTTP response code from querying an API is not 200, but what specific exception should I use? For now I raise an OSError: if response.status_code != 200: raise OSError("Response " + str(response.status_code) + ": " + response.content) I'm aware of the...

Global Exception Handling in play framework java 2.3.7

java,exception,playframework
I am trying to implement global exception handling in Play framework(RESTful) using Java. While searching I found out that extending GlobalSettings and overriding the onError method should handle all errors and give the appropriate response/view. But in the console where I execute "activator run", I still get the ugly stack...

Custom exception handling

c#,exception,windows-phone-8
I am making an app in wp8.1 I want to make sure that during certain process user is not allowed to press the hardware backbutton of windows phone. IF he does then my custom catch block exception should run. I don't know how to handle the backbutton exception for my...

All exceptions are objects in c++?

c++,object,exception
In some literature, like http://en.wikibooks.org/wiki/C%2B%2B_Programming/Exception_Handling , they treat all exceptions as objects, even if they are throwing a fundamental type or a pointer. I want to ask why we call them objects, if sometimes they are not objects. If i don't understand correctly, please correct me....

Can C++ disambiguate the type of an exception object?

c++,exception,exception-handling
With empty exception objects such as, class E1 { }; class E2 { }; Can C++('s compiler or the resulting executable) safely disambiguate between such exception objects in a catch statement? If so, does it mean that a type code for each exception object should be stored and tracked internally?...

When writing a custom iterator, how can I avoid the compiler generating a Reset() method that throws an exception?

c#,exception,iterator
I have coded a custom iterator as a workaround to a complex COM Interop issue. The iterator is about as simple as it gets: public IEnumerator GetEnumerator() { yield return DriveRates.driveSidereal; yield return DriveRates.driveKing; yield return DriveRates.driveLunar; yield return DriveRates.driveSolar; } DriveRates is an enum. My understanding is that the...

A single exception handler for multiple possible exceptions

c#,exception
I would like to check the results from a C# database call to make sure .. The DataTable returned is NOT NULL The DataTable has rows (DataTable.Rows.Count > 1) If either of these conditions are true I want to return the same exception as this type of result is not...

How to get raw Exception Message without HTML in Laravel?

php,ajax,exception,laravel
I make ajax requests to Laravel backend. In backend I check request data and throw some exceptions. Laravel, by default, generate html pages with exception messages. I want to respond just raw exception message not any html. ->getMessage() doesn't work. Laravel, as always, generate html. What shoud I do?...

How to check what constraint has been violated?

java,sql,postgresql,exception
I'm used to check if the user try to store a valid data with cathcing the ConsratinViolationException, like that: try { //persisitng to a db } catch (ConstraintViolationException e){ //Print message } I'm using PostgreSQL and now I'm under the isssue that the persisitng can violate more than one different...

What happens with duplicates when inserting multiple rows?

sql,postgresql,exception,duplicates,upsert
I am running a python script that inserts a large amount of data into a Postgres database, I use a single query to perform multiple row inserts: INSERT INTO table (col1,col2) VALUES ('v1','v2'),('v3','v4') ... etc I was wondering what would happen if it hits a duplicate key for the insert....

AuthenticationException LDAP using plain Java

java,authentication,exception,active-directory,ldap
i have a problem while connecting to an Active Directory via ldap using plain Java. If the displayName begins with a , (Comma e.g. ", name") I get a javax.naming.AuthenticationException. The displayName is never used in the application. Context.SECURITY_PRINCIPAL and Context.SECURITY_CREDENTIALS wich I use dont contain any commas. Can somebody...

exception catching for int divided by 0

c++,exception
Recently i was trying a simple exception program in C++ which goes like this:- #include <iostream> #include <exception> #include <stdexcept> using namespace std; int main() { int x=5, y=0; try { int z=x/y; cout<<"z="<<z; } catch (exception& e) { cout<<"exception caught: "<<e.what(); } return 0; } Why is no exception...

SimpleMembershipProvider WebSecurity.InitializeDatabaseConnection The login from an untrusted domain

asp.net,database,exception,model-view-controller
I export the database to the server and i've problem. When I start application i see this error An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. WebSecurity.InitializeDatabaseConnection("DefaultConnection",...

I have a pdf from which I have to extract data and show but I am getting this exception, I'm not being able to figure out what is this Exception is?

java,exception,servlets,itext,pdf-reader
I have this pdf file to extract data from, but the problem is when I'm running this piece of code as a simple java program, it works like a charm but when I tried this code on JSP servlet it gave out this exception and I'm not being able to...

Error on AS3: TypeError: Error #1010: A term is undefined and has no properties

arrays,actionscript-3,exception,runtime-error
I'm trying to create a collision code involving an array of bullets and an array of zombies. But when it tried this code: for(var bu:int = 0;bu < bullets.length; bu++){ for(var zo:int = 0;zo < zombieCount.length; zo++){ if(bullets[bu].hitTestObject(zombieCount[zo])){ stage.removeChild(zombieCount[zo]); zombieCount.splice(zo, 1); stage.removeChild(bullets[bu]); bullets.splice(bu, 1); trace("hot hit") } } } I...

Java: unhandled exception

java,eclipse,exception,exception-handling,try-catch
I would like to handle an exception but the Eclipse editor is giving me tips which I'm not understanding. This is the method's code: public Collection<String> listOfFriends(String codePerson) throws NoSuchCodeException { Collection<String> s = new LinkedList<>(); try { people.get(codePerson).getFriendsCodes().forEach( code -> s.add(getPerson(code))); } catch (Exception e) { e.printStackTrace(); } return...

IE 11 Error message - Could not complete the operation due to error 800a025e

javascript,html,internet-explorer,exception,internet-explorer-11
I am getting the following error message in IE 11 : Could not complete the operation due to error 800a025e. This error is being thrown when range.select() is called function ExtendSelection() { var sel; if (document.body.createTextRange) { // Internet Explorer var range = document.body.createTextRange(); range.moveStart('character', 0); range.collapse(true); range.moveStart('character', 29); //causes...

Program throws Stack Overflow Error

java,exception,stack-overflow
The following program compiles correctly. What is causing the Stack Overflow Error? How is the exception pushed on to the stack? public class Reluctant { private Reluctant internalInstance = new Reluctant(); public Reluctant() throws Exception { throw new Exception("I’m not coming out"); } public static void main(String[] args) { try...

Changing text of a TextView throws NullPointer Exception

java,android,exception,textview
I'm just following the basic tutorial on the Android website. However, I'm trying to change a few things just for fun. For instance, instead of creating a runtime TextView (as in the tutorial) within the method onCreate(...) of the DisplayMessageActivty class, I've defined a static TextView in the XML layout...

Throw Ignorable Exception

c#,exception
How do I throw an exception that can be ignored if it isn't handled? Say I wanted to make sure a parameter was not null, something like if (param == null) { throw new ArgumentException("Param is null!"); // if the exception isn't handled in the calling code, just return }...

Exception thrown by 'stol' using Visual Studio but not gcc

c++,c++11,exception,visual-studio-2013,gcc4.9
The following code throws an exception when it is run under Visual Studio 2013 but not gcc 4.9.2. The error reported is: 'exception: stol argument out of range' stol returns a long so the size of temp should be big enough to hold the returned value. Can anyone explain the...

Java, default exception messages

java,exception,message,default
Given the following: public abstract class Test { public static void main(String[] args) { int[] testArray = {6, 3, 2}; System.out.println(testArray[3]); } } when I run the program I get: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 at Test1.main(Test1.java:5) In this case the JVM displays the index that is out of...

Getting InputMismatchException at runtime, but compiles fine

java,exception,runtime-error
import java.util.Scanner; public class DRYeck { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //declaration scanner System.out.println("What is given:"); System.out.print("How many sides?"); //input the number of Sides that are given System.out.println(""); double input = scanner.nextInt(); System.out.print("How many angles? "); //input the number of Angles that are given...

Handle global exceptions in VB

vb.net,exception,exception-handling
Hello I have this project experiencing some problems with what is supposed to be my codes for the "problem" handler. Public Event UnhandledException As UnhandledExceptionEventHandler Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim currentDomain As AppDomain = AppDomain.CurrentDomain AddHandler currentDomain.UnhandledException, AddressOf MyHandler End Sub Sub...

FileNotFoundException EACCES (Permission Denied)

android,file,exception,filenotfoundexception
I'm getting an exception that file open permission is denied when I'm trying to open a FileInputStream. File myFile = new File(Environment.getExternalStorageDirectory() .getAbsolutePath() + "/test/test.txt"); try { FileInputStream inStream = new FileInputStream(myFile); // crash Here's the stacktrace: System.err﹕ java.io.FileNotFoundException: /storage/emulated/0/test/test.txt: open failed: EACCES (Permission denied) System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:456) System.err﹕ at...

Loading images with C++/SDL2 - “unhandled exception”, “access violation reading location”

c++,exception,visual-studio-2013,access-violation,sdl-2
I was studying someone else's Pong code for an earlier version of SDL, and I'm trying to get it running with SDL2. Below is an excerpt from my code, which only loads the images. When this code is run, I get a window popping up telling me this: Unhandled exception...

Repeating error message inside a while loop

java,loops,exception,exception-handling
I'm currently working my way through a Udemy Java course and am practicing what i have learnt thus far. I have the following simple program which i am planning on using to get the user to input his name. import java.util.Scanner; public class Adventure { public static final int menuStars...

Try-Except block in python

python,exception
Here is the code that I'm running, basically it just ask the user to type in numbers and then after I type in "done", calculate the average of them: average = 0 total = 0.0 count = 0 while True: num = raw_input() if num == "done": break try: int(num)...

Spring JavaFX @Transactional entitymanager is closed

spring,exception,javafx,transactions,transactional
i'm stuck on a Transactional Problem using Spring @Transactional with a JavaFX application, all my beans, and graphical components are managed by spring. I initialize my appusing @PostConstruct on my Controllers. In the PostConstruct, all my daos are working perfectly but when i invoke a service to save something by...

Exception handler in Node.js

javascript,node.js,exception,exception-handling
I have a very simple question; I have a wrong endpoint and when I try the following code, it throws an exception client.post("http://WrongEndPoint", [], function (data, response) { console.log("data:", data, "response:", response.statusCode); }) ERROR: events.js:72 throw er; // Unhandled 'error' event ^ Error: connect ETIMEDOUT at errnoException (net.js:905:11) at Object.afterConnect...

Making a layout clickable, and start an intent

java,android,xml,exception,android-intent
I wanted to make my layout clickable, which I though would be really easy, but I stumbled into some problems.This is my xml code: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#0D47A1" android:id="@+id/mylayout" android:clickable="true" android:onClick="layout"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:text="sometext"/> </RelativeLayout> and Java code: public void layout (View view){...

Why does TestNG allow several expected exceptions?

java,unit-testing,exception,testng
Why does TestNG have the possibility to check if one of several exceptions are thrown? As far as I know, JUnit only supports one expected exception. Consider the following TestNG dummy examples where both tests will pass: @Test(expectedExceptions = { NullPointerException.class, IllegalArgumentException.class }) public void throwsNullPointer() { throw new NullPointerException();...

Exception when attempting to modify Dictionary

c#,exception,dictionary
I was creating a Dictionary to manage Threads and I ran into this exception when I attempt to clear dead threads after adding some Threads into the dictionary. using System; using System.Collections.Generic; using System.Threading; namespace SysCat { public class ThreadManager { public static readonly ThreadManager GlobalThreadManager = new ThreadManager( );...

C - Windows Exception Handler Invalid Handle

c,windows,winapi,exception,exception-handling
I have a problem about managing an exception. In my code I put hIn = INVALID_HANDLE_VALUE to test the exception, and "null" is a non existing file. My piece of code is __try { hIn = CreateFile (_T("null"), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); hIn = INVALID_HANDLE_VALUE; ReadFile (hIn, buffer,...

java.util.NoSuchElementException when using Scanner.next()

java,exception,java.util.scanner
Java noob working on a project where I'm supposed to display data obtained from a text file onto grids. Project is essentially written, but output displays this exception: run: Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Scanner.java:862) at java.util.Scanner.next(Scanner.java:1371) at inputOutput.ReadDataFile.populateData(ReadDataFile.java:50) at boggle.Boggle.main(Boggle.java:27) Java Result: 1 BUILD SUCCESSFUL (total time: 0...

C# array out of bounds exception error

c#,arrays,exception
I was looking at the code golf section and came across a very interesting coding challenge. I decided to look through the post and noticed there was an example done in C#. To see how it worked, I copied the code and put it into my VS to run and...

Unauthorised access to folders when creating xml file

c#,xml,wpf,exception,unauthorizedaccessexcepti
I'm working on a WPF application where the user sets the target path for an xml file to be created, but I'm always getting an UnauthorizedAccessException, even if the target directory is in my own computer. I've already tried replacing <requestedExecutionLevel level="asInvoker" uiAccess="false" /> with <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> in...

Exception not caught in try catch block

c++,exception
I do a simple throw "TEST THROW" and it isn't caught in my catch (std::exception& e). Is it because I'm catching an std::exception& e? I mean, are only exception classes derived from std::exception caught? If not, am I doing something wrong or is it normal? By the way, none of...

Android XML: RuntimeException: Failed to resolve attribute at index 6

android,xml,exception,android-studio,gradle
Hello dear stackoverflower, In my project, i am using the new "android design library". The problem is, that there is a runtime exception which says(Im trying to create a FloatingButton): java.lang.RuntimeException: Failed to resolve attribute at index 6 at android.content.res.TypedArray.getColorStateList(TypedArray.java:426) at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:91) at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:79) at...

Class with long name

java,android,exception,naming-conventions
Name of Exception class in Java must have Exception suffix also describe its throwing situation. Now I have two exception classes in about primary external storage in Android: /** * Thrown when Application tries to access primary external storage and it is not * available for write.This only depends on...

Java 5 Multi threading, catch thread exceptions

java,multithreading,exception,concurrency,java-5
I've got a class that generates threads (file i/o). I need to catch exceptions in the thread - I don't want to do anything fancy, I want to kill the main thread, rather, stop processing altogether so it can start over. If I catch the exceptions in the thread, that's...

How do I read nothing else but a String using exceptions?

java,string,exception,letter
would you be so kind and help me please? Im doing a simple quiz game, during the game the user is asked to enter his answer. Its either A,B or C. i would like to have this covered with try/catch exceptions... What I want this code to do, is to...

Any way to catch an exception occurring on a thread I don't own?

c#,multithreading,exception
I'm using a crappy third party library because unfortunately I have no choice. This library creates a bunch of threads internally when I call it, and occasionally throws a NullReferenceException on one of these threads. Is there any way for me to catch these exceptions even though I don't own...

Method name expected

c#,arrays,exception
I have to create a json file with an array inside in c# so this is my code but throws an exception: Method name expected before new Dictionary<string, int>[2](); Have you got any suggestions? int[] lung = results.ToArray(); Dictionary<string, Dictionary<string, int>[]> padre = new Dictionary<string, Dictionary<string, int>[]>(); Dictionary<string, int>[] udemy...

The function mask_ is interrupted by asynchronous exception

haskell,exception,asynchronous
import Control.Exception import System.Timeout import Control.Concurrent maskWorker :: IO () maskWorker = mask_ $ do threadDelay 10000 putStrLn $ "Return" uninterruptWorker :: IO () uninterruptWorker = uninterruptibleMask_ $ do threadDelay 10000 putStrLn $ "Return" test :: IO () -> IO () test worker = do pid <- forkIO worker threadDelay...

Throwing an exception in constructor (java)

java,exception,constructor
Utwor(String x, String y, Integer z) { tytul1 = x; wykonawca2 = y; rok3 = z; if (z < 1900 || z > 2015) { System.out.println("Rok utworu musi się zawierać pomiędzy 1900, a 2015."); throw new IllegalArgumentException("Invalid cents value: " + z); } } z is supposed to be between...

Does throwing an Exception have side effects beyond just constructing the exception?

c#,exception
I've got it in my head that throwing an exception has side effects (like collecting stack information), but I'm realizing it might not. Is there a difference between the following two versions of GetException? public Exception GetException() { try { throw new Exception("Bummer"); } catch (Exception e) { return e;...

Mule - Throw Exception with until-successful

java,exception,soap,exception-handling,mule
This is my mule flow: HTTP => Logger => SOAP (CXF) => Until Successful [JAVA] => LOGGER Spring : <spring:beans> <spring:bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <spring:property name="locations"> <spring:list> <spring:value>test.properties</spring:value> </spring:list> </spring:property> </spring:bean> <spring:bean id="testIntegration" class="x.x.x.IntegrationClass" init-method="init">...

Java ArrayIndexOutOfBound

java,arrays,exception,indexoutofboundsexception
I am currently working on a student project and everytime I get this error: ArrayIndexOutOfBoundsException: 7. Can someone see where it occurs and how I can fix it? I know the code looks messy but its just for me. The size of the array is 7. public void actionPerformed(ActionEvent e)...

Display a specific template when Django raises an exception

python,django,exception,django-templates
In my django app, I have multiple places where I raise a specific custom exception DeserializationError. My goal is to show/redirect to a pretty page to show the user this error, including the error message, when this error is raised. Basically, a page that says something like Something went wrong....

Java ArrayIndexOutOfBounds

java,exception,indexoutofboundsexception
Currently working on a student project. I want to figure out the highest number and sort it by bubble sort, the number is parsed from a JLabel, but I get this error everytime. Here is a code snippet: JLabel[] wuerfelsummen = new JLabel[7]; wuerfelsummen[0] = player1_wuerfelsumme; wuerfelsummen[1] = player2_wuerfelsumme; wuerfelsummen[2]...

Proper use of custom exceptions

c#,exception,exception-handling
I'm creating a function and want it to be able to give meaningful error message whenever it encounter an error. I would like to ask whether this situation is a proper use of custom exception, and if not what is appropriate way to handle it. Example : int res =...

BufferedWriter closed throws exception

java,android,exception,bufferedwriter
I have made a method to write a log in an external storage of Android. public int writeLog(String clase, String metodo, Object object){ try{ File folder = new File(Environment.getExternalStorageDirectory(), Constants.ROUTE_FILES_TEXT); if (!folder.exists()) { folder.mkdir(); } FileWriter fw = new FileWriter(folder.toString() + "/log.txt", true); BufferedWriter out = new BufferedWriter(fw); out.write("Hora: "...

Java Threads with ConcurrentModificationException

java,multithreading,exception,arraylist,concurrentmodification
I'm currently working on my first multithreaded software - a program, which calculates prime numbers... Basically I create n (number of Threads) runnables. These runnables are added to an ArrayList. They check, whether a number is a prime. If the number is a prime I add it into an...

Laravel 5 Customexception

php,exception,laravel-5
I'm playing around with Laravel5 to test out custom exception. But It returns the error Call to a member function send() on string and I can't really figure out why. 1.routes.php 2.App/Exceptions/toshikiER.php 3.composer.php 4.App/Exceptions/Hanlder.php ...

Retry on database exception using php

php,exception,mysqli
I have been working on exceptions thrown by php - mysqli & created this snippet below that tries to check a few times to see if a temp glitch has caused the database to fail. if so, it tries to recover. If it cannot then it quits/ ends. Now while...

Cannot access closed file during Reading/Writing operation - C#

c#,exception,binaryreader,binarywriter
I have searched the internet and viewed many posts, but none has helped me. So I decided to ask my own question over here. I am writing some data to binary file when the save button on my form is clicked, and reading that data from the file when the...

signal() : any performance impact?

c++,c,exception,signals,sigsegv
I need to catch SIGABRT, SIGSEGV and SIGILL to present the user a proper critical error message when something out of my control fails and the program need to exit. However my program does a lot of realtime computing, so performance is important. Does signal() ( http://www.cplusplus.com/reference/csignal/signal/ ) cause any...

how exception finds correct catch block

java,exception
I was wondering how catch block works. I have below code, catch(ArithmeticException e){ System.out.println("task1 is completed"); } catch(ArrayIndexOutOfBoundsException e){ System.out.println("task 2 completed"); } catch(Exception e){ System.out.println("common task completed"); } If divide by zero occurs it will go to Arithmetic Exception and skips rest. How is it internally implemented so that...

How to instrument the byte code to tell when a catch clause is being executed?

java,exception,bytecode
Based on Brett Walker's comment to this question, I was wondering how it can be done. "If you want to fail the unit test, in the most general sense, when ever a catch clause is executed by the code in this method you are going to have to instrument the...

android - No Activity found to handle intent action.VIEW

android,exception,android-intent,android-fragments,textview
I got an exception in my android app: 06-18 17:57:39.816 6333-6333/com.appsrox.instachat E/InputEventReceiver﹕ Exception dispatching input event. 06-18 17:57:39.816 6333-6333/com.appsrox.instachat E/MessageQueue-JNI﹕ Exception in MessageQueue callback: handleReceiveCallback 06-18 17:57:39.816 6333-6333/com.appsrox.instachat E/MessageQueue-JNI﹕ android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=href (has extras) } at...

Struts 2 add exception mapping for certain actions

java,exception,struts2,struts-config
Consider a project with lots of annotated actions. public class TransferMoney(){ @Action("transfer-money-show-form") public String showForm(); @Action("transfer-money-confirm") public String confirmForm(); @Action("transfer-money-result") public String result(); } I want to add exception-mapping to confirmForm so I can do it as: @Action(value = "transfer-money-confirm", exceptionMappings = [email protected]( exception = "java.lang.Exception", result = "exception") }...

Hashing String (SHA-256) in an ActionListener class

java,exception,event-listener,checked-exceptions
I want to use the following code in an ActionListener class. MessageDigest digest = MessageDigest.getInstance("SHA-256"); byte[] hash = digest.digest(key.getBytes("UTF-8")); BigInteger HashValue = new BigInteger(javax.xml.bind.DatatypeConverter.printHexBinary(hash).toLowerCase(), 16); String HashValueString = HashValue.toString(); But the "SHA-256" and "UTF-8" can't be imported in any way. When I do this in a console program, I can...

CInvalidArgumentException when checking class in PreTranslateMessage

c++,exception,visual-c++,mfc
The case: I'd like to make shortcuts with numpad so users can use my application fast. I implemented this in PreTranslateMessage and this worked. But the case is that I have an Edit Control where the user should enter some number. So at the time the user has focus on...

trap exceptions comprehensively in Jython

exception,exception-handling,jython,throwable
This is my attempt so far to trap all exceptions in Jython code. The most difficult thing, I find, is trapping exceptions when you override a method from a Java class: with the "vigil" decorator below (which also tests whether the EDT/Event Despatch Thread status is correct) you can find...

Laravel MethodNotAllowedHttpException

php,forms,exception,laravel,request
I am currently creating a website that, once the user arrives, they are greeted by a form with which they input their unique id and DoB. Upon entering the information and clicking submit, they are sent to the main form which has only a little information on it and the...

String returned positive booleans, despite not fulfilling any [closed]

java,eclipse,exception
import java.util.Scanner; public class Driver { public static void main(String[] args) { String userName; boolean good = false; boolean good1 = false; boolean good2 = false; boolean good3 = false; do{ Scanner scan = new Scanner(System.in); System.out.print("Please enter username: "); userName=scan.next(); try { checkForUpper(userName); good = true; } catch (MustHaveUpperCaseException...

Linq to Entity - error on ICollection (code first)

c#,linq,entity-framework,exception,linq-to-entities
so We used a code first approach to build the database. I have come across an issue and am having very little success resolving it. the DB class (EF - code first) public partial class Object1 { [Key] public Guid uid { get; set; } public int sequenceNumber { get;...

Why Eclipse Debugger does not stop on scoped exception breakpoint (how to stop on handled exception)

java,eclipse,debugging,exception
I am using Eclipse Luna (tested also in Kepler so not version specific). Run on JDK 1.8_40. I would like to find places with "eaten" exceptions - e.g. inproperly handled with try/catch block. Example code below. When I am setting Exception breakpoint as on picture e.printStackTrace() does not stop with...

What's the benefit of exceptions specification in Java?

java,c++,exception,specifications
I came to Java from C++. Both in Java and C++ we have the possibility to specificate exceptions. It looks like this: void function_name() throw(Exception) { ... if (error) { throw Exception("Error"); } ... } As I know, writing exceptions specification is considered to be a bad practice in C++....

Exception calling “ExecuteNonQuery”

sql-server,powershell,exception
When I attempt to insert new data in database via PowerShell, it works. However, if the data is already in database, I get exception. Someone had similar problem, Catch exception calling "ExecuteNonQuery", but I believe I am using the correct SQL statement in my PowerShell code, where I say SELECT...

Exception error using C++ Thread Pool Library (CTPL)

c++,multithreading,exception,visual-studio-2013,threadpool
I am trying to use the C++ Thread Pool Library (CTPL), which pleasantly consists in a single header file. For this, I created a very simple test program. Here is the code : #include <iostream> #include "ctpl_stl.h" void myFunction(int threadID_0) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } int main() { ctpl::thread_pool p(2); // We...

Fatal Exception Main Android Null Pointer Exception

android,exception,nullpointerexception,main
I am having an issue with this weather app that I am making with TreeHouse I have asked a question on their forums, but no avail. Here are my two files in question... MainActivity package com.megliosolutions.stormy; import android.content.Context; import android.graphics.drawable.Drawable; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.util.Log;...

errors not being thrown after promise

javascript,exception,promise
i have a weird situation i would like to know how to solve. in my app errors that happen after functions with promises do net get thrown and the app just stalls. here an example: getTenant = (req) -> deferred = Q.defer() deferred.resolve('foo') if req.info.referrer deferred.resolve('bar') if !req.info.referrer deferred.promise Routes...

Exception message best practices when aligning messages

c#,.net,exception
We have an exceptions library that is expected to be used over several solutions. We have several custom exception types contained within this library. The question that has arisen: If we want to align error messages being used in these exceptions, what is the best practise way to accomplish this?...