Search Results

Search found 16643 results on 666 pages for 'exception handling'.

Page 20/666 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • How and where do we write try catch block to handle Exception

    - by Arpita
    We are using C# language to develope a Windows application. Our windows application consists of three layers (UI,Business and DataAccess layer). In Business Layer there are some public (business) methods through which UI communicates wilh Business layer classes. These public methods also have some private methods to implement the required functionality. There are some methods in DataAcess layer which are called from Business layer class. In this situatuion where should i wrte try-catch? a) In Business Layer Public methods b) In Busyness Layer Private methods c) In DataAccess Layer methods d) In UI methods from where Business methods are called.

    Read the article

  • webViewDidFinishLoad exception

    - by Nava Carmon
    Hi, I have a screen with a webView in my navigation controller stack and when I navigate from this view back to a previous before the page completely loaded I get a EXCEPTION_BAD_ACCESS. Seems, that the view with a webView being released before it comes to webViewDidFinishLoad function. My question is how to overcome this problem? I don't expect from the user to wait till the page loads... The code is very simple: - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; NSURL *url = [NSURL URLWithString:storeUrl]; //URL Requst Object NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; //Load the request in the UIWebView. [browser loadRequest:requestObj]; } TIA

    Read the article

  • Miller-rabin exception number?

    - by nightcracker
    Hey everyone. This question is about the number 169716931325235658326303. According to http://www.alpertron.com.ar/ECM.HTM it is prime. According to my miller-rabin implementation in python with 7 repetitions is is composite. With 50 repetitions it is still composite. With 5000 repetitions it is STILL composite. I thought, this might be a problem of my implementation. So I tried GNU MP bignum library, which has a miller-rabin primality test built-in. I tested with 1000000 repetitions. Still composite. This is my implementation of the miller-rabin primality test: def isprime(n, precision=7): if n == 1 or n % 2 == 0: return False elif n < 1: raise ValueError("Out of bounds, first argument must be > 0") d = n - 1 s = 0 while d % 2 == 0: d //= 2 s += 1 for repeat in range(precision): a = random.randrange(2, n - 2) x = pow(a, d, n) if x == 1 or x == n - 1: continue for r in range(s - 1): x = pow(x, 2, n) if x == 1: return False if x == n - 1: break else: return False return True And the code for the GMP test: #include <gmp.h> #include <stdio.h> int main(int argc, char* argv[]) { mpz_t test; mpz_init_set_str(test, "169716931325235658326303", 10); printf("%d\n", mpz_probab_prime_p(test, 1000000)); mpz_clear(test); return 0; } As far as I know there are no "exceptions" (which return false positives for any amount of repetitions) to the miller-rabin primality test. Have I stumpled upon one? Is my computer broken? Is the Elliptic Curve Method wrong? What is happening here? EDIT I found the issue, which is http://www.alpertron.com.ar/ECM.HTM. I trusted this applet, I'll contact the author his applet's implementation of the ECM is faulty for this number. Thanks. EDIT2 Hah, the shame! In the end it was something that went wrong with copy/pasting on my side. NOR the applet NOR the miller-rabin algorithm NOR my implementation NOR gmp's implementation of it is wrong, the only thing that's wrong is me. I'm sorry.

    Read the article

  • FileNotFound exception when trying to write to a file

    - by Chris Knight
    OK, I'm feeling like this should be easy but am obviously missing something fundamental to file writing in Java. I have this: File someFile = new File("someDirA/someDirB/someDirC/filename.txt"); and I just want to write to the file. However, while someDirA exists, someDirB (and therefore someDirC and filename.txt) do not exist. Doing this: BufferedWriter writer = new BufferedWriter(new FileWriter(someFile)); throws a FileNotFoundException. Well, er, no kidding. I'm trying to create it after all. Do I need to break up the file path into components, create the directories and then create the file before instantiating the FileWriter object?

    Read the article

  • warning C6242: A jump out of this try-block forces local unwind

    - by Benjamin
    When we use SEH with __finally block, if we do return in __try block, it causes a local unwind. To Local unwind, the system need to approximately 1000 instructions. The local unwind causes a warning C6242. MSDN suggests using __leave keyword(with saving a return value). But I don't think it's a good idea. If we save a return value and leave the block, there will be many mistakes. Is the waring really necessary? What do you prefer?

    Read the article

  • feof() in C file handling

    - by Neeraj
    I am reading a binary file byte-by-byte,i need determine that whether or not eof has reached. feof() doesn't works as "eof is set only when a read request for non-existent byte is made". So, I can have my custom check_eof like: if ( fread(&byte,sizeof(byte),1,fp) != 1) { if(feof()) return true; } return false; But the problem is, in case when eof is not reached, my file pointer is moved a byte ahead. So a solution might be to use ftell() and then fseek() to get it to correct position. Another solution might be to buffer the byte ahead in some temporary storage. Any better solutions?

    Read the article

  • Centralized error handling in VB6.

    - by AngryHacker
    I have the following method that all the error handlers call: Public Function ToError(strClass As String, strMethod As String) As String On Error GoTo errHandle ToError = "Err " & Err.Number & _ ", Src: " & Err.Source & _ ", Dsc: " & Err.Description & _ ", Project: " & App.Title & _ ", Class: " & strClass & _ ", Method: " & strMethod & _ ", Line: " & Erl Err.Clear exitPoint: Exit Function errHandle: oLog.AddToLog "Error in ToError Method: " & Err.Description, False Resume exitPoint End Function It turns out that because I declare an error handler in this function On Error GoTo errHandle, VB6 clears the error before I am able to record it. Is there a way to prevent the 'On Error GoTo errHandle' statement from clearing the error?

    Read the article

  • Handling asynchronous responses

    - by James P.
    I'm building an FTP client from scratch and I've noticed that the response codes aren't immediate (which is no surprise). What would be a good approach for getting the corresponding code to a command? Below is an example of the output of Filezilla server. The response code is the three digits near the end of each line. (000057) 23/05/2010 19:43:10 - (not logged in) (127.0.0.1)> Connected, sending welcome message... (000057) 23/05/2010 19:43:10 - (not logged in) (127.0.0.1)> 220-FileZilla Server version 0.9.12 beta (000057) 23/05/2010 19:43:10 - (not logged in) (127.0.0.1)> 220-written by Tim Kosse ([email protected]) (000057) 23/05/2010 19:43:10 - (not logged in) (127.0.0.1)> 220 Please visit http://sourceforge.net/projects/filezilla/ (000057) 23/05/2010 19:43:10 - (not logged in) (127.0.0.1)> user anonymous (000057) 23/05/2010 19:43:10 - (not logged in) (127.0.0.1)> 331 Password required for anonymous

    Read the article

  • Java: custom-exception-error

    - by HH
    $ javac TestExceptions.java TestExceptions.java:11: cannot find symbol symbol : class test location: class TestExceptions throw new TestExceptions.test("If you see me, exceptions work!"); ^ 1 error Code import java.util.*; import java.io.*; public class TestExceptions { static void test(String message) throws java.lang.Error{ System.out.println(message); } public static void main(String[] args){ try { // Why does it not access TestExceptions.test-method in the class? throw new TestExceptions.test("If you see me, exceptions work!"); }catch(java.lang.Error a){ System.out.println("Working Status: " + a.getMessage() ); } } }

    Read the article

  • Exception while opening file

    - by viswanathan
    Hi I have a VC++ application and in my application i have some basic file operations. Below is the defaulting code CStdioFile cFile; CFileException e; CString sReport; CString sHtmlfile = "testreport.html" OutputDebugString((sHtmlfile)); if (!cFile.Open(sHtmlfile,CFile::modeCreate | CFile::modeWrite, &e )) { } The problem is my application executes this piece of code every few minutes. and it works fine. After several runs of the code the cFile.Open() function fails. I tried to get the error message TCHAR szError[1024]; e.GetErrorMessage(szError,1024); OutputDebugString((szError)); The irony is the szError error message is "No error occured". This again works once i restart my application. Any idea why this occurs. Thanks in advance.

    Read the article

  • Ruby: Continue a loop after catching an exception

    - by Santa
    Basically, I want to do something like this (in Python, or similar imperative languages): for i in xrange(1, 5): try: do_something_that_might_raise_exceptions(i) except: continue # continue the loop at i = i + 1 How do I do this in Ruby? I know there are the redo and retry keywords, but they seem to re-execute the "try" block, instead of continuing the loop: for i in 1..5 begin do_something_that_might_raise_exceptions(i) rescue retry # do_something_* again, with same i end end

    Read the article

  • Handling Errors in PHP

    - by Mike
    I have a custom class that, when called, will redirect to a page and send a 'message_type' and 'message' variable via GET. When the page opens it checks for these variables and displays a 'success', 'warning', or 'error' message depending on the 'message_type' variable. I made it so the user thinks they stay on the same page. It also allows for other variables to be passed along with the message. Is this good practice, or should I just start using exceptions? Example: //Call a static function that will redirect to a page, with an error message RedirectWithMessage::go('somepage.php', MessageType::ERROR, 'Error message here.'); The following checkMessage() function is an include file: function checkMessage() { if((isset($_GET['message_type']) && strlen($_GET['message_type'])) && (isset($_GET['message']) && strlen($_GET['message_type']))) { DisplayMessage::display($_GET['message_type'], $_GET['message']); return true; } return false; } On the page that is redirected to, call checkMessage(); //If a message is received, display it. If not, do nothing checkMessage(); I know this might be vague, and I can supply more code if necessary. I guess the issue is that I don't have much experience using exceptions, but I think they seem cumbersome (writing try-catch blocks everywhere). Please let me know if I am making this more difficult for myself or if there is a better solution. Thanks! Mike

    Read the article

  • jQuery event handling with .live() problem with setInterval and clearInterval

    - by Kyle Lafkoff
    jQuery 1.4.2: I have an image. When the mouseover event is triggered, a function is executed that runs a loop to load several images. On the contrary, the mouseout event needs to set the image back to a predetermined image and no longer have the loop executing. These are only for the images with class "thumb": $("img.thumb").live("mouseover mouseout", function(event) { var foo = $(this).attr('id'); var wait; var i=0; var image = document.getElementById(foo); if (event.type == 'mouseover') { function incrementimage() { i++; image.src = 'http://example.com/images/file_'+i+'.jpg'; if(i==30) {i=0;} } wait = setInterval(incrementimage,500); } else if (event.type == 'mouseout') { clearInterval (wait); image.src = 'http://example.com/images/default.jpg'; } return false; }); When I mouseout, the image is set to the default.jpg but the browser continues to loop though the images. It will never stop. Can someone hit me with some knowledge? Thanks.

    Read the article

  • NHibernate GenericADO Exception

    - by Ris90
    Hi, I'm trying to make simple many-to-one association, using NHibernate.. I have class Recruit with this mapping: <class name="Recruit" table="Recruits"> <id name="ID"> <generator class="native"/> </id> <property name="Lastname" column="lastname"/> <property name="Name" column="name"/> <property name="MedicalReport" column="medicalReport"/> <property name="DateOfBirth" column ="dateOfBirth" type="Date"/> <many-to-one name="AssignedOnRecruitmentOffice" column="assignedOnRecruitmentOffice" class="RecruitmentOffice"/> which is many-to-one connected to RecruitmentOffices: <class name="RecruitmentOffice" table="RecruitmentOffices"> <id name="ID" column="ID"> <generator class="native"/> </id> <property name="Chief" column="chief"/> <property name="Name" column="name"/> <property name ="Address" column="address"/> <set name="Recruits" cascade="save-update" inverse="true" lazy="true"> <key> <column name="AssignedOnRecruitmentOffice"/> </key> <one-to-many class="Recruit"/> </set> And create Repository class with method Insert: public void Insert(Recruit recruit) { using (ITransaction transaction = session.BeginTransaction()) { session.Save(recruit); transaction.Commit(); } } then I try to save new recrui to base: Recruit test = new Recruit(); RecruitmentOffice office = new RecruitmentOffice(); ofice.Name = "test"; office.Chief = "test"; test.AssignedOnRecruitmentOffice = office; test.Name = "test"; test.DateOfBirth = DateTime.Now; RecruitRepository testing = new RecruitRepository(); testing.Insert(test); And have this error GenericADOException could not insert: [OSiUBD.Models.DAO.Recruit][SQL: INSERT INTO Recruits (lastname, name, medicalReport, dateOfBirth, assignedOnRecruitmentOffice) VALUES (?, ?, ?, ?, ?); select SCOPE_IDENTITY()] on session.Save

    Read the article

  • Error handling in PHP

    - by Industrial
    Hi guys, We're building a PHP app based on Good old MVC (codeigniter framework) and have run into trouble with a massive chained action that consists of multiple model calls, that together is a part of a big transaction to the database. We want to be able to do a list of actions and get a status report of each one back from the function, whatever the outcome is. Our first initial idea was to utilize the exceptions of PHP5, but since we want to also need status messages that doesnt break the execution of the script, this was our solution that we came up with. It goes a little something like this: $sku = $this->addSku( $name ); if ($sku === false) { $status[] = 'Something gone terrible wrong'; $this->db->trans_rollback(); return $status; } $image= $this->addImage( $filename); if ($image=== false) { $error[] = 'Image could not be uploaded, check filesize'; $this->db->trans_rollback(); return $status; } Our controller looks like this: $var = $this->products->addProductGroup($array); if (is_array($var)) { foreach ($var as $error) { echo $error . '<br />'; } } It appears to be a very fragile solution to do what we need, but it's neither scalable, neither effective when compared to pure PHP exceptions for instance. Is this really the way that this kind of stuff generally is handled in MVC based apps? Thanks!

    Read the article

  • C++ wxWidgets Event Handling

    - by Wallter
    Q1:I am using wxWidgets (C++) and have come accost a problem that i can not locate any help. I have created several wxTextCtrl boxes and would like the program to update the simple calculations in them when the user 'kills the focus.' I could not find any documentation on this subject on the wxWidgets webpage and Googling it only brought up wxPython. The two events i have found are: EVT_COMMAND_KILL_FOCUS - EVT_KILL_FOCUS for neither of which I could find any snippet for. Could anyone give me a short example or lead me to a page that would be helpful? Q2:Would i have to create an event to handle the focus being killed for each of my 8 wxTextCtrl boxes? In the case that i have to create a different event: How would i get each event to differentiate from each other? I know i will have to create new wxID's for each of the wxTextCtrl boxes but how do I get the correct one to be triggered? class BasicPanel : public wxPanel { ... wxTextCtrl* one; wxTextCtrl* two; wxTextCtrl* three; wxTextCtrl* four; ... }

    Read the article

  • Best practice for handling ConnectionDroppedHandler in OCS Server Application

    - by Paul Nearney
    Hi all, In general, it seems that the majority of times that ConnectionDroppedHandler would get called in an OCS server application is for expected reasons e.g. server application has been unregistered, server is shutting down, etc. Are there any unexpected situations in which ConnectionDroppedHandler can be called? Basically, i'm wondering whether it will ever be necessary to log an error to the event log from this event handler. Many thanks, Paul

    Read the article

  • Action Controller: Exception - ID not found

    - by Danny McClelland
    Hi Everyone, I am slowly getting the hang of Rails and thanks to a few people I now have a basic grasp of the database relations and associations etc. You can see my previous questions here: http://stackoverflow.com/questions/2714621/rails-database-relationships I have setup my applications models with all of the necessary has_one and has_many :through etc. but when I go to add a kase and choose from a company from the drop down list - it doesnt seem to be assigning the company ID to the kase. You can see a video of the the application and error here: http://screenr.com/BHC You can see a full breakdown of the application and relevant source code at the Git repo here: http://github.com/dannyweb/surveycontrol If anyone could shed some light on my mistake I would be appreciate it very much! Thanks, Danny

    Read the article

  • System.Web.AspNetHostingPermission Exception on New Deployment

    - by Jason N. Gaylord
    I have a friend that is moving a web application from one server over to another. The new server has the same settings as the first server, however, he's running into a Security issue. Here's the error details: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. The Event Viewer does not point to anything specific in the web.config file or anything. The web applicaiton is on the C: drive. This is a Windows Server 2008 R2 x64 server with a brand new IIS 7 installation. IIS is set in classic mode for this app pool.

    Read the article

  • Should the PHP community start using more discriptive Exceptions?

    - by fireeyedboy
    I work with Zend Framework a lot and I just took a peek at Kohana, and it strikes me as odd that this is a typical scenario in these frameworks: throw Some_Componenents_Exception( 'invalid argument' ); Where I believe this wouldn't be mouch more useful: throw Some_Components_InvalidArgumentException( 'whatever discription' ); Because it is easier to catch. I suspect, but immediately admit it's prejudiced, that the former practice is common in the PHP community. Should we, the PHP community, start using these descriptive types of expections more?

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >