exception

java.io.EOFException error on object serialization with HttpHandler

我怕爱的太早我们不能终老 提交于 2019-12-24 02:21:43
问题 I am trying to serialize an object in a HttpHandler class. I have 2 files, Server3.java : package server3; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.Serializable; import java.net.InetSocketAddress; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; public class Server3 { public static void main(String[] args) throws Exception { HttpServer server =

Java Scanner Take Input, call a method, then back to read more input not working

喜你入骨 提交于 2019-12-24 02:16:12
问题 I have a class called PlayGame , and in the main method I have this chunk of code: public class PlayGame { public static void main(String args[]) { while (true) { System.out.println("Where would you like your adventure to begin? (Enter a number)\n"); System.out.println("1. Play the Game\n2. Quit the Game"); Scanner userInput = new Scanner(System.in); String userAction; try { userAction = userInput.nextLine().trim(); if (userAction.equals("1")) { pressPlay(); } else if (userAction.equals("2"))

Is this a proper way to use exceptions?

强颜欢笑 提交于 2019-12-24 02:10:38
问题 I have a Membership exception which looks like this: public enum MembershipError { EmailNotFound, EmailNotConfirmed, IncorrectPassword, EmailExists } public class MembershipException : ApplicationException { public MembershipError MembershipError { get; set; } public MembershipException(MembershipError membershipError) : base(Enum.GetName(typeof (MembershipError), membershipError)) { MembershipError = membershipError; } } Should I use an enum in my exception or make an exception for each enum

How can I fix 'No exception of type SomeException can be thrown; an exception type must be a subclass of Throwable'

妖精的绣舞 提交于 2019-12-24 02:08:27
问题 I have java webstart app and want to use app API for testing purposes. So I get required (as I assumed) library from webserver and install it to maven repository. And all is fine except custom exception which received No exception of type SomeException can be thrown; an exception type must be a subclass of Throwable As I understand from similar topics - some jar library is missing, is there some way to know which one? or maybe there is other way to fix this? (of course I can install all jars

Prevent C++ DLL exception using try catch internally

会有一股神秘感。 提交于 2019-12-24 02:04:46
问题 I'm developing a C++ DLL that allocate an array for the main application. The function return an error code and not the pointer to the new created array, so the address of the first member will be written in a parameter of the function. Example: int foo(int** arrayPtr) { int* array = new int[10]; *arrayPtr = array; return 0; } So, in the main I call the function that way: int* myArray; int ret; ret = foo(&myArray); Now myArray points to the new created array. QUESTION 1: Is there a better way

Handling exceptions in a class library enveloping a device driver

…衆ロ難τιáo~ 提交于 2019-12-24 01:55:42
问题 I am writing a class library that envelopes an USB device driver. This device has its own class library, provided by the hardware vendor. Very often, especially if you handle with old DLL or COM assemblies, there are methods (functions to be correct) that return TRUE if all was OK, or FALSE if any error happen. Often these methods return information about the error in one of their parameters or separately in a GetLastError method or even if in an OnError event. Now, normally I handle all

Getting InteropServices.SEHException on DllImport routine during debug after migrating project from .NET Framework 3.5 to 4.0

ⅰ亾dé卋堺 提交于 2019-12-24 01:55:25
问题 I have written an application that interfaces with the winspool print driver, and its been working just fine for months. I need to move my projects from .NET Framework 3.5 to 4.0 to include a coworkers assemblies, but doing this (and only doing this) causes one of my .dll imported method calls to fail when executing from the VS 2010 IDE. Both the debug and release binaries still work if I run them outside of the Visual Studio 2010 environment. Below is the line that now fails after moving to

App crashes with exception before Activity.onCreate() Java android

﹥>﹥吖頭↗ 提交于 2019-12-24 01:54:24
问题 I get this weird exception: libcore.io.ErrnoException: access failed: ENOENT (No such file or directory) All I did was that I modified res/layout/main_activity.xml But when I roll back to the previous situation, I get same exception. I know this looks like the problem is elsewhere, but I just can't figure where. Any hints, please ? Here is part of the back trace in the relevant thread: This is an export of back trace of the main thread. Problem is in the top most line. <1> main@830012765280,

How do I catch ArgumentError for my whole app in Rails?

不羁的心 提交于 2019-12-24 01:47:11
问题 Environment RAILS 3.1 Ruby 1.9.1 I have tried in the application_controller but that doesn't seem to work. Anything I may be doing wrong? rescue_from ArgumentError do |exception| flash.now[:error] = "Arguments for your request are incorrect" #ExceptionNotifier::Notifier.background_exception_notification(exception).deliver if Rails.env.production? redirect_to root_url, :alert => exception.message end The exceptions I am trying to deal with A ArgumentError occurred in marketplace#index: invalid

Beautifulsoup Exception list out of range

南笙酒味 提交于 2019-12-24 01:44:55
问题 I'm using beautifulsoup to do the following: section = soup.findAll('tbody')[0] How can set variable like that using the first list item... without it throwing an exception to: IndexError: list index out of range if BS4 can't find tbody? Any ideas? 回答1: You can return the answer from findAll and chek it's length first: x = soup.findAll("tbody") if x is not None and len(x) > 0: section = x[0] 回答2: Everyone who parses HTML will run into this type a question. The element you are looking for is