Search Results

Search found 13191 results on 528 pages for 'unhandled exception'.

Page 164/528 | < Previous Page | 160 161 162 163 164 165 166 167 168 169 170 171  | Next Page >

  • Is there anything wrong with my Factory class?

    - by Alex
    class PieceFactory { @SuppressWarnings("rawtypes") public Piece createPiece(String pieceType) throws Throwable{ Class pieceClass = Class.forName(pieceType); Piece piece = (Piece) pieceClass.newInstance(); return piece; } } I'm not all used to handling exceptions yet therefore I'm just throwing them, but everywhere I use a method that uses this factory it tells me I have to throw exceptions like throwable. For example, in one of my classes I have a method that instantiates a lot of objects using the method that uses the factory. I can use the method in that class by just throwing the exception, however it won't work if I try to pass a reference to that class to another class and then use the method from there. Then it forces me to try catch the exception. I probably don't need a factory but it seemed interesting and I'd like to try to use patterns. The reason I created the factory was that I have 6 subclasses of Piece and I wan't to use a method to instantiate them by passing the type of subclass I want as an argument to the method.

    Read the article

  • CouchDB Map/Reduce raises execption in reduce function?

    - by fuzzy lollipop
    my view generates keys in this format ["job_id:1234567890", 1271430291000] where the first key element is a unique key and the second is a timestamp in milliseconds. I run my view with this elapsed_time?startkey=["123"]&endkey=["123",{}]&group=true&group_level=1 and here is my reduce function, the intention is to reduce the output to get the earliest and latest timestamps and return the difference between them and now function(keys,values,rereduce) { var now = new Date().valueOf(); var first = Number.MIN_VALUE; var last = Number.MAX_VALUE; if (rereduce) { first = Math.max(first,values[0].first); last = Math.min(last,values[0].last); } else { first = keys[0][0][1]; last = keys[keys.length-1][0][1]; } return {first:now - first, last:now - last}; } and when processing a query it constantly raises the following execption: function raised exception (new TypeError("keys has no properties", "", 1)) I am making sure not to reference keys inside my rereduce block. Why does this function constantly raise this exception?

    Read the article

  • How to document thrown exceptions in c#/.net

    - by Arnold Zokas
    I am currently writing a small framework that will be used internally by other developers within the company. I want to provide good Intellisense information, but I am not sure how to document thrown exceptions. In the following example: public void MyMethod1() { MyMethod2(); // also may throw InvalidOperationException } public void MyMethod2() { System.IO.File.Open(somepath...); // this may throw FileNotFoundException // also may throw DivideByZeroException } I know the markup for documenting exceptions is: /// <exception cref="SomeException">when things go wrong.</exception> What I don't understand is how to document exceptions thrown by code called by MyMethod1()? Should I document exceptions thrown by MyMethod2() Should I document exceptions thrown by File.Open() ? What would be the best way to document possible exceptions?

    Read the article

  • How to access File over the Network

    - by Polo
    Hi! I am having a hard time on this one, I have a folder over the network with public access (no credential restriction). I am trying to do a File.Exist or Directory.Exist and I keep on having a exception. Can someone tell me the good way to do IO over the network. EDIT 1 FOR DETAILS: if i do execture = \agoodip\Public\test.txt I get the file etc etc In my code it look like a basic Directory.Exist(@"\\agoodip\Public") or File.exist(@"\\agoodip\Public\test.txt") The exception I get is Path not found. EDIT 2 : I am using Silverlight 3, Is there any security pattern to be aware of to lookup file on the network? Thanks!

    Read the article

  • How to translate,use JSON in GWT?

    - by graybow
    I'm new in gwt. and need to know how to use JSON in gwt so i try this simple data loader but i'm still confuse. I create a project named 'tesdb3' in eclipse. I create the PHP side to access the database, and made the output as JSON.. I create the userdata.php in folder war. then I compile tesdb3 project. Folder tesdb3 and the userdata.php in war moved in local server(I use WAMP). I put the PHP in folder tesdb3. This is the result from my localhost/phpmyadmin/tesdb3/userdata.php [{"kode":"002","nama":"bambang gentolet"}{"kode":"012","nama":"Algiz"}] From that result I think the PHP side was working good.Then I create UserData.java as JSNI overlay like this: package com.tesdb3.client; import com.google.gwt.core.client.JavaScriptObject; class UserData extends JavaScriptObject{ protected UserData() {} public final native String getKode() /*-{ return this.kode; }-*/; public final native String getNama() /*-{ return this.nama; }-*/; public final String getFullData() { return getKode() + ":" + getNama(); } } Then Finally in the tesdb3.java: public class Tesdb3 implements EntryPoint { String url= "http://localhost/phpmyadmin/tesdb3/datauser.php"; private native JsArray<UserData> getuserdata(String Json) /*-{ return eval(json); }-*/; public void LoadData() throws RequestException{ RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url)); builder.sendRequest(null, new RequestCallback(){ @Override public void onError(Request request, Throwable exception) { Window.alert("error " + exception); } public void onResponseReceived(Request request, Response response) { getuserdata(response.getText()); //this is how i use the userdata json(is this already translated?) UserData UD = null; String LKode =UD.getKode(); String LName =UD.getNama(); Label L = new Label(LKode+""+LName); RootPanel.get().add(L); } }); } public void onModuleLoad() { try { LoadData(); } catch (RequestException e) { e.printStackTrace(); } } } The result is blank(i use development mode). and there was an eror like this:(I show it just some part) 10:46:29.984 [ERROR] [tesdb3] Uncaught exception escaped com.google.gwt.core.client.JavaScriptException: (ReferenceError): json is not defined fileName: http://localhost:1092 lineNumber: 2 stack: ("")@http://localhost:1092:2 My question is: How I use the translated Json in right way?? Is there any wrong use from my code? Is that necessary to move the compiled project to local server folder?(i do it following a tutorial from google). Sorry too many ask. but i'm really really confused.

    Read the article

  • Constructor invocation returned null: what to do?

    - by strager
    I have code which looks like: private static DirectiveNode CreateInstance(Type nodeType, DirectiveInfo info) { var ctor = nodeType.GetConstructor(new[] { typeof(DirectiveInfo) }); if(ctor == null) { throw new MissingMethodException(nodeType.FullName, "ctor"); } var node = ctor.Invoke(new[] { info }) as DirectiveNode; if(node == null) { // ???; } return node; } I am looking for what to do (e.g. what type of exception to throw) when the Invoke method returns something which isn't a DirectiveNode or when it returns null (indicated by // ??? above). (By the method's contract, nodeType will always describe a subclass of DirectiveNode.) I am not sure when calling a constructor would return null, so I am not sure if I should handle anything at all, but I still want to be on the safe side and throw an exception if something goes wrong.

    Read the article

  • Resizing uploaded files in django using PIL

    - by Nikunj
    I am using PIL to resize an uploaded file using this method: def resize_uploaded_image(buf): imagefile = StringIO.StringIO(buf.read()) imageImage = Image.open(imagefile) (width, height) = imageImage.size (width, height) = scale_dimensions(width, height, longest_side=240) resizedImage = imageImage.resize((width, height)) return resizedImage I then use this method to get the resizedImage in my main view method: image = request.FILES['avatar'] resizedImage = resize_uploaded_image(image) content = django.core.files.File(resizedImage) acc = Account.objects.get(account=request.user) acc.avatar.save(image.name, content) However, this gives me the 'read' error. Trace: Exception Type: AttributeError at /myapp/editAvatar Exception Value: read Any idea how to fix this? I have been at it for hours! Thanks! Nikunj

    Read the article

  • GAE transaction exceptions

    - by bach
    Hi, In this example IS the exception being thrown if ANY of the Table elements are being changed by another client OR only if the element that we changed has been changed by another client? Just to verify - the exception is thrown from the commit() isn't it? PersistenceManager pm = PMF.get().getPersistenceManager(); try { pm.currentTransaction().begin(); List<Row> Table = (List<Row>) pm.newQuery(query).execute(); Table.get(0).setReserved(true); // <----- we change only this element pm.currentTransaction().commit(); } catch (JDOCanRetryException ex) { pm.currentTransaction().rollback() // <----- if Table.get(1) was changed by another client do we get to this point??? }

    Read the article

  • Best practice for Python Assert

    - by meade
    Is there a performance or code maintenance issue with using assert as part of the standard code instead of using it just for debugging purposes? Is assert x >= 0, 'x is less then zero' and better or worse then if x < 0: raise Exception, 'x is less then zero' Also, is there anyway to set a business rule like if x < 0 raise error that is always checked with out the try, except, finally so, if at anytime throughout the code x is < 0 an error is raised, like if you set assert x < 0 at the start of a function, anywhere within the function where x becomes less then 0 an exception is raised?

    Read the article

  • how to filter data from xml file for displaying only selected as nodes in treeview

    - by michale
    I have an xml file named "books.xml" provided in the link "http://msdn.microsoft.com/en-us/library/windows/desktop/ms762271(v=vs.85).aspx". What my requirement was to disaplay only the <title> from xml information as nodes in tree view. But when i did the following coding its displaying all the values as nodes like "catalog" as rootnode, book as parent node for all then author,title,genre etc as nodes but i want only root node catalogue and title as nodes not even book. Can any body guide me what modification i need to do in the exisitng logic for displaying title as nodes OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Open XML document"; dlg.Filter = "XML Files (*.xml)|*.xml"; dlg.FileName = Application.StartupPath + "\\..\\..\\Sample.xml"; if (dlg.ShowDialog() == DialogResult.OK) { try { //Just a good practice -- change the cursor to a //wait cursor while the nodes populate this.Cursor = Cursors.WaitCursor; //First, we'll load the Xml document XmlDocument xDoc = new XmlDocument(); xDoc.Load(dlg.FileName); //Now, clear out the treeview, //and add the first (root) node treeView1.Nodes.Clear(); treeView1.Nodes.Add(new TreeNode(xDoc.DocumentElement.Name)); TreeNode tNode = new TreeNode(); tNode = (TreeNode)treeView1.Nodes[0]; //We make a call to addTreeNode, //where we'll add all of our nodes addTreeNode(xDoc.DocumentElement, tNode); //Expand the treeview to show all nodes treeView1.ExpandAll(); } catch (XmlException xExc) //Exception is thrown is there is an error in the Xml { MessageBox.Show(xExc.Message); } catch (Exception ex) //General exception { MessageBox.Show(ex.Message); } finally { this.Cursor = Cursors.Default; //Change the cursor back } }} //This function is called recursively until all nodes are loaded private void addTreeNode(XmlNode xmlNode, TreeNode treeNode) { XmlNode xNode; TreeNode tNode; XmlNodeList xNodeList; if (xmlNode.HasChildNodes) //The current node has children { xNodeList = xmlNode.ChildNodes; for (int x = 0; x <= xNodeList.Count - 1; x++) //Loop through the child nodes { xNode = xmlNode.ChildNodes[x]; treeNode.Nodes.Add(new TreeNode(xNode.Name)); tNode = treeNode.Nodes[x]; addTreeNode(xNode, tNode); } } else //No children, so add the outer xml (trimming off whitespace) treeNode.Text = xmlNode.OuterXml.Trim(); }

    Read the article

  • enterprise libaray confiuration 4.0

    - by prince23
    hi, i am using enterprise libaray confiuration 4.0. and here i have set the file size as rollSizeKB="20" but once my file size reaches 9kb. a new file is created. what is te issue. why is it creating new file once ut reaches 9KB. <add fileName="c:\Exception.log" footer="----------------------------------------" formatter="Text Formatter" header="----------------------------------------" rollFileExistsBehavior="Increment" rollInterval="None" rollSizeKB="20" timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="Timestamp" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Exception Policy" /> any help would be great thank you

    Read the article

  • AJAX works fine in firefox, but malfunctions in Mozilla Prism 0.9

    - by Babiker
    I have the following ajax fucntion: function ajax(value, url, urlVarname, displayContainers_id){ if(value == ''){ document.getElementById(displayContainers_id).innerHTML=''; } /* THIS IS LINE 12*/ xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState == 4 && xmlhttp.status == 200){ document.getElementById(displayContainers_id).innerHTML=xmlhttp.responseText; } } xmlhttp.open('GET',url + '?varName=' + urlVarname + '&value=' + value, true); /* THIS IS LINE 25 */ xmlhttp.send(); } onmousedown="ajax(document.getElementById('searchParamater').value, 'http://192.168.0.7/controllers/search_controller.php', document.getElementById('searchBy').value, 'ajaxBucket')"> This whole thing works fine in firefox but when i use prism 0.9, it malfunctions and i get the following error in the errors console: Warning: assignment to undeclared variable xmlhttp Source File: http://192.168.0.7/javascript/main.js Line: 12 Error: uncaught exception: [Exception... "Not enough arguments [nsIXMLHttpRequest.send]" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://192.168.0.7/javascript/main.js :: ajax :: line 25" data: no]

    Read the article

  • SSIS process files from folder

    - by RT
    Background: I've a folder that gets pumped with files continuously. My SSIS package needs to process the files and delete them. The SSIS package is scheduled to run once every minute. I'm picking up the files in ascending order of file creation time. I'm building an array of files and then processing-deleting them one at a time. Problem: If an instance of my package takes longer than one minute to run, the next instance of the SSIS package will pick up some of the files the previous instance has in its buffer. By the time the second instance of teh package gets around to processing a file, it may already have been deleted by the first instance, creating an exception condition. I was wondering whether there was a way to avoid the exception condition. Thanks.

    Read the article

  • Different kinds of doubles in vb.net?

    - by Jonathan
    Hey all- I'm using QBFC to generate invoices in a Quickbooks integrating app. I'm getting an exception thrown for lineItem.Amount.SetValue(val as Double) when I try to enter a programmatically generated double. The following does not work: lineItem = invoice.ORInvoiceLineAddList.Append.InvoiceLineAdd Dim amount as Double amount = summary.dailySold * summary.dailyRate loggingTxtBox.AppendText("Amount is " & amount & vbNewLine) lineItem.Amount.SetValue(amount) The exception I receive is System.Runtime.InteropServices.COMException (0x80040305): Invalid Amount format. at Interop.QBFC8.IQBAmountType.SetValue(Double val) The following works: lineItem.Amount.SetValue(20.3) Any suggestions? Is .NET interpretting a hard-coded double differently than a programmatically calculated one? Thanks- Jonathan

    Read the article

  • problems calling webservices through the https connection

    - by shivaji123
    i have done an application in BlackBerry which takes username & password with url link which is a link of server here i am calling some webservices but it is doing the connection in https so when i take the username password & url link & hit the login button it basically calls a webservice but then the application connecting to the webservice for ever & after some time i get the error massage something "unreported exception the application is not responding" .& then the application crashes out.Also i am using the SOAP client library . this is the piece of code synchronized (this) { try { _httpconn = (HttpConnection) Connector.open(url,Connector.READ_WRITE);//Connector.READ_WRITE //_httpconn =(StreamConnection)Connector.open(url); //System.out.println("-----------httpsconnection() PART--------------------"); _httpconn.setRequestMethod(HttpConnection.POST); //_httpconn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); //System.out.println("-----------httpsconnection() PART- **-------------------"); _httpconn.setRequestProperty("SOAPAction", Constants.EXIST_STR); //System.out.println("-----------httpsconnection() PART-REQUEST -------------------"); _httpconn.setRequestProperty("Content-Type", "text/soap+xml"); //System.out.println("-----------httpsconnection() PART- CONTENT-------------------"); _httpconn.setRequestProperty("User-Agent", "kSOAP/1.0"); //System.out.println("-----------httpsconnection() PART-USER Agent-------------------"); String clen = Integer.toBinaryString(input.length()); _httpconn.setRequestProperty("Content-Length", clen); //System.out.println("-----------httpsconnection() Content-Length--------------------"); _out = _httpconn.openDataOutputStream(); //System.out.println(input+"-----------input--------------------"+url); _out.write(input.getBytes()); _out.flush(); // may or may not be needed. //int rc = _httpconn.getResponseCode(); int rc = _httpconn.getResponseCode(); if(rc == HttpConnection.HTTP_OK) { isComplete = true; _in = _httpconn.openInputStream(); msg = new StringBuffer(); byte[] data = new byte[1024]; int len = 0; int size = 0; while ( -1 != (len = _in.read(data)) ) { msg.append(new String(data, 0, len)); size += len; } responsData = msg.toString(); System.out.println("-----------responsData "+responsData); } if(responsData!=null) isSuccessful = true; stop(); } catch (InterruptedIOException interrIO) { //errStr = "Network Connection hasn't succedded. "+ //"Please check APN setting."; UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Status.show("Network Connection hasn't succedded. "+ "Please try again later."); } }); isComplete = true; System.out.println(interrIO); stop(); } catch (IOException interrIO) { System.out.println("-----------IO EXCEPTION--------- "+interrIO); //errStr = "Network Connection hasn't succedded. "+ //"Please check APN setting." ; UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Status.show("Network Connection hasn't succedded. "+ "Please try again later." ); } }); isComplete = true; System.out.println(interrIO); stop(); } catch (Exception e) { System.out.println(e); //errStr = "Unable to connect to the internet at this time. "+ //"Please try again later."; UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Status.show("Unable to connect to the internet at this time. "+ "Please try again later." ); } }); isComplete = true; stop(); } finally { try { if(_httpconn != null) { _httpconn.close(); _httpconn = null; } if(_in != null) { _in.close(); _in = null; } if(_out != null) { _out.close(); _out = null; } } catch(Exception e) { System.out.println(e); UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Status.show("Unable to connect to the internet at this time. "+ "Please try again later." ); } }); } } } } can anybody help me out. Thanks in advance

    Read the article

  • How to handle sharepoint web services exceptions

    - by Royson
    Hi, I have developed an application of share point. I am using web services for that. the problem is that while working with my app sometimes i get some exceptions. like, Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown. Stack Strace :: at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at ......... my methods From this exception i cannot understand the main problem. While developing i can debug the code, but now my application is getting launched..i can get error log file from my client which contains this type of excetions. But how to catch exact error.??? Thanks.

    Read the article

  • Mockito upgrade causes null pointer problems

    - by Ann Addicks
    We upgraded from mockito-all-1.8.5.jar to mockito-all-1.9.0.jar and now see null pointers when using annotations for the classes being mocked. Here is an example: @Mock private static IAccountManager accountManager; @Mock private static IBusinessUnitManager businessUnitManager; private static Gson parser; @InjectMocks private static DownloadController downloadController; @BeforeClass public static void setUpBeforeClass() throws Exception { parser = new Gson(); downloadController = new DownloadController(accountManager, businessUnitManager, parser); } @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); Mockito.reset(accountManager, businessUnitManager); } As soon as accountManager is referenced in the download controller, it throws a npe. This worked in 1.8.5.

    Read the article

  • Continuous Form, how to add/update records with external connection

    - by Mohgeroth
    EDIT After some more research I found that I cannot use a continuous form with an unbound form since it can only reference a single record at a time. Given that I've altered my question... I have a sample form that pulls out data to enter into a table as an intermediary. Initially the form is unbound and I open connections to two main recordsets. I set the listbox's recordset equal to one of them and the forms recordset equal to the other. The problem is that I cannot add records or update existing ones. Attempting to key into the fields does nothing almost as if the field was locked (Which it is not). Settings of the recordsets are OpenKeyset and LockPessimistic. Tables are not linked, they come from an outside access database seperate from this project and must remain that way. I am using an adodb connection to get the data. Could the separation of the data from the project be causing this? Sample Code from the Form Option Compare Database Option Explicit Private conn As CRobbers_Connections Private exception As CError_Trapping Private mClient_Translations As ADODB.Recordset Private mUnmatched_Clients As ADODB.Recordset Private mExcluded_Clients As ADODB.Recordset //Construction Private Sub Form_Open(Cancel As Integer) Set conn = New CRobbers_Connections Set exception = New CError_Trapping Set mClient_Translations = New ADODB.Recordset Set mUnmatched_Clients = New ADODB.Recordset Set mExcluded_Clients = New ADODB.Recordset mClient_Translations.Open "SELECT * FROM Client_Translation" _ , conn.RBRS_Conn, adOpenKeyset, adLockPessimistic mUnmatched_Clients.Open "SELECT DISTINCT(a.Client) as Client" _ & " FROM Master_Projections a " _ & " WHERE Client NOT IN ( " _ & " SELECT DISTINCT ClientID " _ & " FROM Client_Translation);" _ , conn.RBRS_Conn, adOpenKeyset, adLockPessimistic mExcluded_Clients.Open "SELECT * FROM Clients_Excluded" _ , conn.RBRS_Conn, adOpenKeyset, adLockPessimistic End Sub //Add new record to the client translations Private Sub cmdAddNew_Click() If lstUnconfirmed <> "" Then AddRecord End If End Sub Private Function AddRecord() With mClient_Translations .AddNew .Fields("ClientID") = Me.lstUnconfirmed .Fields("ClientAbbr") = Me.txtTmpShort .Fields("ClientName") = Me.txtTmpLong .Update End With UpdateRecords End Function Private Function UpdateRecords() Me.lstUnconfirmed.Requery End Function //Load events (After construction) Private Sub Form_Load() Set lstUnconfirmed.Recordset = mUnmatched_Clients //Link recordset into listbox Set Me.Recordset = mClient_Translations End Sub //Destruction method Private Sub Form_Close() Set conn = Nothing Set exception = Nothing Set lstUnconfirmed.Recordset = Nothing Set Me.Recordset = Nothing Set mUnmatched_Clients = Nothing Set mExcluded_Clients = Nothing Set mClient_Translations = Nothing End Sub

    Read the article

  • How to display specific data from a file

    - by user1067332
    My program is supposed to ask the user for firstname, lastname, and phone number till the users stops. Then when to display it asks for the first name and does a search in the text file to find all info with the same first name and display lastname and phones of the matches. import java.util.*; import java.io.*; import java.util.Scanner; public class WritePhoneList { public static void main(String[] args)throws IOException { BufferedWriter output = new BufferedWriter(new FileWriter(new File( "PhoneFile.txt"), true)); String name, lname, age; int pos,choice; try { do { Scanner input = new Scanner(System.in); System.out.print("Enter First name, last name, and phone number "); name = input.nextLine(); output.write(name); output.newLine(); System.out.print("Would you like to add another? yes(1)/no(2)"); choice = input.nextInt(); }while(choice == 1); output.close(); } catch(Exception e) { System.out.println("Message: " + e); } } } Here is the display code, when i search for a name, it finds a match but displays the last name and phone number of the same name 3 times, I want it to display all of the possible matches with the first name. import java.util.*; import java.io.*; import java.util.Scanner; public class DisplaySelectedNumbers { public static void main(String[] args)throws IOException { String name; String strLine; try { FileInputStream fstream = new FileInputStream("PhoneFile.txt"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); Scanner input = new Scanner(System.in); System.out.print("Enter a first name"); name = input.nextLine(); strLine= br.readLine(); String[] line = strLine.split(" "); String part1 = line[0]; String part2 = line[1]; String part3 = line[2]; //Read File Line By Line while ((strLine= br.readLine()) != null) { if(name.equals(part1)) { // Print the content on the console System.out.print("\n" + part2 + " " + part3); } } }catch (Exception e) {//Catch exception if any System.out.println("Error: " + e.getMessage()); } } }

    Read the article

  • Test, if object was deleted

    - by justik
    Look to the following code, please: class Node { private: double x, y; public: Node (double xx, double yy): x(xx), y(yy){} }; int main() { Node *n1 = new Node(1,1); Node *n2 = n1; delete n2; n2 = NULL; if (n1 != NULL) //Bad test { delete n1; //throw an exception } } There are two pointers n1, n2 pointed to the same object. I would like to detect whether n2 was deleted using n1 pointer test. But this test results in exception. Is there any way how to determine whether the object was deleted (or was not deleted) using n1 pointer ? Thanks for your help.

    Read the article

  • Constructor invokation returned null: what to do?

    - by strager
    I have code which looks like: private static DirectiveNode CreateInstance(Type nodeType, DirectiveInfo info) { var ctor = nodeType.GetConstructor(new[] { typeof(DirectiveInfo) }); if(ctor == null) { throw new MissingMethodException(nodeType.FullName, "ctor"); } var node = ctor.Invoke(new[] { info }) as DirectiveNode; if(node == null) { // ???; } return node; } I am looking for what to do (e.g. what type of exception to throw) when the Invoke method returns something which isn't a DirectiveNode or when it returns null (indicated by // ??? above). (By the method's contract, nodeType will always describe a subclass of DirectiveNode.) I am not sure when calling a constructor would return null, so I am not sure if I should handle anything at all, but I still want to be on the safe side and throw an exception if something goes wrong.

    Read the article

  • Rails: common approach for handling exceptions in restful actions on objects that have been destroye

    - by Greg
    It is very common in Rails for an objects_controller controller to have RESTful edit and destroy actions like so: def edit @object = Object.find(params[:id]) end def destroy @object = Object.find(params[:id]) @object.destroy redirect_to :back end With an associated view that provides edit and destroy links like so: <%= link_to "Edit the Object", edit_object_path(object) %> <%= link_to "Delete", object, :confirm => 'Are you sure?', :method => :delete %> And it is easy to blow this up. If I open two browser windows, A and B, destroy an object with the "Delete" link in browser A and then press the "Edit" link in browser B, the find() in the edit action throws an exception. Obviously there are several ways to deal with this in the edit action: catch the exception and recover gracefully use @object = find(:first, "conditions... etc. and test the @object before going further But seeing as this is such a common pattern, I would love to know how other folks deal with this situation.

    Read the article

  • java.util.MissingResourceException

    - by ashwani66476
    Hello Crew I am getting below exception while running an application. This application read abc.properties file, Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name abc, locale en_US at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:853) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:822) at java.util.ResourceBundle.getBundle(ResourceBundle.java:566) at com.ibm.dst.DailyExtract.getResourceBundle(DailyExtract.java:104) at com.ibm.dst.DailyExtract.main(DailyExtract.java:131) abc.properties file reside at the workspace. I am using RSA7 as IDE, is there any setting problem? any suggestions are welcome..... Thanks a lot in advance

    Read the article

  • TcpListener Socket still active after program exits.

    - by lnical
    I'm trying to stop a TCP Listener as my program is exiting. I do not care about any data that is currently active on the socket or any of the active client sockets. The socket clean up code is essentially: try { myServer.Server.Shutdown(SocketShutdown.Both) } catch (Exception ex) { LogException(ex) } myServer.Server.Close(0) myServer.Stop() myServer is a TCPListener On some occasions, Shutdown will thrown an exception System.Net.Sockets.SocketException: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied at System.Net.Sockets.Socket.Shutdown(SocketShutdown how) When this happens, the socket is never released. Even after the application exits netstat shows the socket is still in the listening state. I have not been able to create definitive reproduction scenerio, it happens at seemingly random times. Client Sockets are cleaned up independently. Do you have any suggestions to help me make this socket die?

    Read the article

  • IIS7 integrated mode closing token between requests

    - by user607287
    We are migrating to IIS7 integrated mode and have come across an issue. We authenticate using WindowsAuthentication but then store a reference to the WindowsPrincipal so that on future requests we can authorize as needed against AD. In IIS 7 Integrated mode, the token is being closed (between requests) so that when we try to run IsInRole it generates a disposed exception. Is there a way to cache this token or change our use of WindowsPrincipal so that we don't need to make successive AD requests to get it for each authorization request? Here is the exception being thrown from WindowsPrincipal.IsInRole("") - System.ObjectDisposedException: {"Safe handle has been closed"} Thanks.

    Read the article

< Previous Page | 160 161 162 163 164 165 166 167 168 169 170 171  | Next Page >