Search Results

Search found 19541 results on 782 pages for 'event handling'.

Page 12/782 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Handling PHP exceptions with JQuery

    - by Itamar Bar-Lev
    Hello, I'm using JQuery to call a PHP function that returns a JSON string upon success or throws some exceptions. Currently I'm calling jQuery.parseJSON() on the response and if it fails I assume the response contains an exception string. $.ajax({ type: "POST", url: "something.php", success: function(response){ try { var json = jQuery.parseJSON(response); } catch (e) { alert(response); return -1; } // ... do stuff with json } Can anyone suggest a more elegant way to catch the exception? Many thanks, Itamar

    Read the article

  • Programming Concepts: What should be done when an exception is thrown?

    - by Dooms101
    This does not really apply to any language specifically, but if it matters I am using VB.NET in Visual Studio 2008. I can't seem to find anything really that useful using Google about this topic, but I was wondering what is common practice when an exception is thrown and caught but since it has been thrown the application cannot continue operating. For example I have exceptions that are thrown by my FileLoader class when a file cannot be found or when a file is deemed corrupt. The exception is only thrown within the class and is not handled really. If the error is detected, then the exception is thrown and whatever function is was thrown is basically quits. So in the code trying to create that object or call one of its members I use a Try...Catch statement. However, I was wondering, what should even do when this exception is caught? My application needs these files to be intact, and if they are not, the application is almost useless. So far I just pop up a message box telling the user their is an error and to reinstall. What else can I do, or better, what's common practice in these situations?

    Read the article

  • Pylons error handling

    - by TJ Huffington
    Hello, I am just getting started with Pylons and am confused as to how to account for exceptions. What is the proper way to error check user input (ensure a correct email address, check that it doesn't yet exist in the database, etc ...)? Should these checks go inside the model classes or somewhere else? Sample code would be great.

    Read the article

  • Error Handling for Application in PHP

    - by Zubair1
    I was wondering if someone can show me a good way to handle errors in my PHP app, that i am also easily able to reuse in my codes. So far i have been using the following functions: Inline Errors function display_errors_for($fieldname) { global $errors; if (isset($errors[$fieldname])) { return '<label for="' .$fieldname. '" class="error">' . ucfirst($errors[$fieldname]). '</label>'; } else { return false; } } All Errrors function display_all_errors($showCounter = true) { global $errors; $counter = 0; foreach ($errors as $errorFieldName => $errorText) { if ($showCounter == true) { $counter++; echo '<li>' . $counter . ' - <label for="' .$errorFieldName. '">' .$errorText. '</label></li>'; } else { echo '<li><label for="' .$errorFieldName. '">' .$errorText. '</label></li>'; } } } I have a $errors = array(); defined on the top of my global file, so it is appended to all files. The way i use it is that if i encounter an error, i push a new error key/value to the $errors array holder, something like the following: if (strlen($username) < 3) { $errors['username'] = "usernames cannot be less then 3 characters."; } This all works great and all, But i wondering if some one has a better approach for this? with classes? i don't think i want to use Exceptions with try/catch seems like an overkill to me. I'm planning to make a new app, and i'll be getting my hands wet with OOP alot, though i have already made apps using OOP but this time i'm planning to go even deeper and use OOP approach more extensively. What i have in mind is something like this, though its just a basic class i will add further detail to it as i go deeper and deeper in my app to see what it needs. class Errors { public $errors = array(); public function __construct() { // Initialize Default Values // Initialize Methods } public function __destruct() { //nothing here too... } public function add($errorField, $errorDesc) { if (!is_string($errorField)) return false; if (!is_string($errorDesc)) return false; $this->errors[$errorField] = $errorDesc; } public function display($errorsArray) { // code to iterate through the array and display all errors. } } Please share your thoughts, if this is a good way to make a reusable class to store and display errors for an entire app, or is getting more familiar with exceptions and try/catch my only choice?

    Read the article

  • ASP.NET Exception Handling in background threads

    - by Xodarap
    When I do ThreadPool.QueueUserWorkItem, I don't want unhandled exceptions to kill my entire process. So I do something like: ThreadPool.QueueUserWorkItem(delegate() { try { FunctionIActuallyWantToCall(); } catch { HandleException(); } }); Is this the recommended pattern? It seems like there should be a simpler way to do this. It's in an asp.net-mvc app, if that's relevant.

    Read the article

  • Websphere exception handling

    - by Benjamin
    Hi all, From a security standpoint, what is the best solution to handle application errors with Websphere? I've been thinking of creating a class that is called every time an application error is generated, log the error and display a generic error message to the users. In PHP this can be achieved using the set_exception_handler() function. Is there something similar for websphere that could be configured in the web.xml? I've found codes like this on the internet: <error-page> <error-code>500</error-code> <location>/servlet/ExceptionHandlerServlet</location> </error-page> But that would only work with "500" HTTP error codes. I really want something generic that catches everything. Something like a class that implements a certain interface which can have access to all information about the error. Thanks for your time.

    Read the article

  • Ruby on Rails bizarre behavior with ActiveRecord error handling

    - by randombits
    Can anyone explain why this happens? mybox:$ ruby script/console Loading development environment (Rails 2.3.5) >> foo = Foo.new => #<Foo id: nil, customer_id: nil, created_at: nil, updated_at: nil> >> bar = Bar.new => #<Bar id: nil, bundle_id: nil, alias: nil, real: nil, active: true, list_type: 0, body_record_active: false, created_at: nil, updated_at: nil> >> bar.save => false >> bar.errors.each_full { |msg| puts msg } Real can't be blank Real You must supply a valid email => ["Real can't be blank", "Real You must supply a valid email"] So far that is perfect, that is what i want the error message to read. Now for more: >> foo.bars << bar => [#<Bar id: nil, bundle_id: nil, alias: nil, real: nil, active: true, list_type: 0, body_record_active: false, created_at: nil, updated_at: nil>] >> foo.save => false >> foo.errors.to_xml => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>\n <error>Bars is invalid</error>\n</errors>\n" That is what I can't figure out. Why am I getting Bars is invalid versus the error messages displayed above, ["Real can't be blank", "Real you must supply a valid email"] etc. My controller simply has a respond_to method with the following in it: format.xml { render :xml => @foo.errors, :status => :unprocessable_entity } How do I have this output the real error messages so the user has some insight into what they did wrong?

    Read the article

  • Graceful DOS Command Error-Handling w/PHP popen()

    - by Captain Obvious
    PHP 5.2.13 on Windows 2003 I am using the DOS Start /B command to launch a background application using the PHP popen() function: popen("start /B {$_SERVER['HOMEPATH']}/{$app}.exe > {$_SERVER['HOMEPATH']}/bg_output.log 2>&1 & echo $!", 'r'); The popen() function launches a cmd.exe process that runs the specified command; however, if the command fails (e.g. the {$app}.exe doesn't exist or is locked in the above example), the cmd.exe process never returns, and PHP hangs indefinitely as a result. Calling the failing DOS command directly using the Command Prompt results in an Error prompt that requires clicking the OK button. I assume this error confirmation requirement is what's preventing the cmd.exe process from returning to PHP both from the Command Prompt (using both CGI and CLI) and the web (using Apache 2.0 handler w/Apache 2.2). Is there a way to configure PHP, Apache, and/or Win 2003 to return the DOS error to the originating call rather than waiting for confirmation?

    Read the article

  • Jquery click event propagation

    - by ozsenegal
    I've a table with click events bind to it rows (tr). Also,there're A elements with it owns click events assigned inside those rows. Problem is when i click on A element,it also fires click event from TD.And Im dont want this behavior,i just want to fire A click's event. Code: //Event row TR $("tr:not(:first)").click(function(){ $(".window,.backFundo,.close").remove(); var position = $(this).offset().top; position = position < 0 ? 20 : position; $("body").append($("<div></div>").addClass("backFundo")); $("body").append($("<div></div>").addClass("window").html("<span class=close><img src=Images/close.png id=fechar /></span>").append("<span class=titulo>O que deseja fazer?</span><span class=crud><a href=# id=edit>Editar</a></span><span class=crud><a href=# id=delete codigo=" + $(this).children("td:first").html() + ">Excluir</a></span>").css({top:"20px"}).fadeIn("slow")); $(document).scrollTop(0); }); //Element event $("a").live("click",function(){alert("clicked!");}); Whenever you click the anchor it fires event from it parent row.Any ideas?

    Read the article

  • best practice on precedence of variable declaration and error handling in C

    - by guest
    is there an advantage in one of the following two approaches over the other? here it is first tested, whether fopen succeeds at all and then all the variable declarations take place, to ensure they are not carried out, since they mustn't have had to void func(void) { FILE *fd; if ((fd = fopen("blafoo", "+r")) == NULL ) { fprintf(stderr, "fopen() failed\n"); exit(EXIT_FAILURE); } int a, b, c; float d, e, f; /* variable declarations */ /* remaining code */ } this is just the opposite. all variable declarations take place, even if fopen fails void func(void) { FILE *fd; int a, b, c; float d, e, f; /* variable declarations */ if ((fd = fopen("blafoo", "+r")) == NULL ) { fprintf(stderr, "fopen() failed\n"); exit(EXIT_FAILURE); } /* remaining code */ } does the second approach produce any additional cost, when fopen fails? would love to hear your thoughts!

    Read the article

  • What is the suggested way to show exception messages on UI which were produced in Business Layer?

    - by burak ozdogan
    Hi, Is there a pattern OR 'a best practice' on creating user's friendly messages in the presentation layer by using exceptions which were thrown from the Business Layer? Actually in many cases I prefer to throw Application Exceptions and this is forcing me to catch them on UI (aspx.cs pages). And if the process is complex which may produce many different types of exceptions I have to have many catch blocks to produce specific error messages. Is there a better way coming to your mind? A pattern maybe for similar cases? thanks

    Read the article

  • Best practice for error handling in an Android Service

    - by Omar Kohl
    I have an Android Service that does some background processing on an image using a separate Thread. If an error occurs in this Service or even worse in the thread, what is the best practice to inform the launching Activity of the problem and allow the application to recover to a stable state (i.e. the state it was in before launching the service). From within the Service I could post a Toast or a Notification, but that doesn't help me. I would like to inform the user about the problem but at the same time recover the application to a stable state.

    Read the article

  • wxWidgets exception handling

    - by Alex Farber
    When unhandled exception is handled in wxWidgets application in Windows, program shows Abort-Retry-Ignore message produced by Widgets exception handler. I want to get normal unhandled exception behavior: program should terminate with standard Windows unhandled exception dialog. Can I prevent Widgets to catch unhahnled exceptions?

    Read the article

  • Handling multiple exceptions

    - by the-banana-king
    Hi there, I have written a class which loads configuration objects of my application and keeps track of them so that I can easily write out changes or reload the whole configuration at once with a single method call. However, each configuration object might potentially throw an exception when doing IO, yet I do not want those errors to cancel the overall process so that the other objects are still given a chance to reload/write. Therefore I collect all exceptions which are thrown while iterating over the objects and store them in a super-exception, which is thrown after the loop, since each exception must still be handled and someone has to be notified of what exactly went wrong. However, that approach looks a bit odd to me. Someone out there with a cleaner solution? Here is some code of the mentioned class: public synchronized void store() throws MultipleCauseException { MultipleCauseException me = new MultipleCauseException("unable to store some resources"); for(Resource resource : this.resources.values()) { try { resource.store(); } catch(StoreException e) { me.addCause(e); } } if(me.hasCauses()) throw me; }

    Read the article

  • Graceful DOS Command Error-Handling

    - by Captain Obvious
    PHP 5.2.13 on Windows 2003 I am using the DOS Start /B command to launch a background application using the PHP popen() function: popen("start /B {$_SERVER['HOMEPATH']}/{$app}.exe > {$_SERVER['HOMEPATH']}/bg_output.log 2>&1 & echo $!", 'r'); The popen() function launches a cmd.exe process that runs the specified command; however, if the command fails (e.g. the {$app}.exe doesn't exist or is locked in the above example), the cmd.exe process never returns, and PHP hangs indefinitely as a result. Calling the failing DOS command directly using the Command Prompt results in an Error prompt that requires clicking the OK button. I assume this error confirmation requirement is what's preventing the cmd.exe process from returning to PHP both from the Command Prompt (using both CGI and CLI) and the web (using Apache 2.0 handler w/Apache 2.2). Is there a way to write the DOS command or configure the server or cmd.exe app itself to return the DOS error to the originating call rather than waiting for confirmation?

    Read the article

  • ASP.NET AJAX WebForms custom error handling question

    - by Vilx-
    I've made a web application that has the following architecture: Every form is a UserControl, there is just one actual page (Default.aspx), and a parameter in the URL specifies which UserControl to load. The UserControl is loaded in an UpdatePanel so that it can enjoy full AJAX-iness. There is also an elaborate message displaying mechanism that I use. Eventually messages end up in one designated area on top of the Default.ASPX with some nice formatting 'n stuff. Now, I would also like to capture any unhandled exceptions that originate in the UserControl and display it in this area with all the bells-and-whistles that I've made for messages. How can I do this? The Page.Error and ScriptManager.AsyncPostBackError somehow don't work for me...

    Read the article

  • Exception Handling in google app engine

    - by Rahul99
    i am raising exception using if UserId == '' and Password == '': raise Exception.MyException , "wrong userId or password" but i want print the error message on same page class MyException(Exception): def __init__(self,msg): Exception.__init__(self,msg)

    Read the article

  • iPhone Exception Handling

    - by Coocoo4Cocoa
    I have one crash in my iPhone application that does throw an NSException. The crash reports are completely ambiguous in where the error is and what exactly is causing it. Is there a smart way for me to set a top level exception handler somewhere to see what is causing it? I can't replicate the problem myself, but a few of my beta users certainly can. What's a smart way to handle a problem of this nature?

    Read the article

  • Exception handling - what happens after it leaves catch

    - by Tony
    So imagine you've got an exception you're catching and then in the catch you write to a log file that some exception occurred. Then you want your program to continue, so you have to make sure that certain invariants are still in a a good state. However what actually occurs in the system after the exception was "handled" by a catch? The stack has been unwound at that point so how does it get to restore it's state?

    Read the article

  • Is this WPF error handling a good idea ?

    - by Adiel
    I have a multi threaded wpf application with various HW interfaces. I want to react to several HW failures that can happen. For example : one of the interfaces is a temperature sensor and i want that from a certain temp. a meesage would appear and notify the user that it happened. i came up with the follwing design : /// <summary> /// This logic reacts to errors that occur during the system run. /// The reaction is set by the component that raised the error. /// </summary> public class ErrorHandlingLogic : Logic { } the above class would consume ErrorEventData that holds all the information about the error that occurred. public class ErrorEventData : IEventData { #region public enum public enum ErrorReaction { } #endregion public enum #region Private Data Memebers and props private ErrorReaction m_ErrorReaction; public ErrorReaction ErrorReactionValue { get { return m_ErrorReaction; } set { m_ErrorReaction = value; } } private string m_Msg; public string Msg { get { return m_Msg; } set { m_Msg = value; } } private string m_ComponentName; public string ComponentName { get { return m_ComponentName; } set { m_ComponentName = value; } } #endregion Private Data Memebers and props public ErrorEventData(ErrorReaction reaction, string msg, string componenetName) { m_ErrorReaction = reaction; m_Msg = msg; m_ComponentName = componenetName; } } the above ErrorHandlingLogic would decide what to do with the ErrorEventData sent to him from various components of the application. if needed it would be forwarded to the GUI to display a message to the user. so what do you think is it a good design ? thanks, Adiel.

    Read the article

  • C# Event Handlers Using an Enum

    - by Jimbo
    I have a StatusChanged event that is raised by my object when its status changes - however, the application needs to carry out additional actions based on what the new status is. e.g If the new status is Disconnected, then it must update the status bar text and send an email notification. So, I wanted to create an Enum with the possible statuses (Connected, Disconnected, ReceivingData, SendingData etc.) and have that sent with the EventArgs parameter of the event when it is raised (see below) Define the object: class ModemComm { public event CommanderEventHandler ModemCommEvent; public delegate void CommanderEventHandler(object source, ModemCommEventArgs e); public void Connect() { ModemCommEvent(this, new ModemCommEventArgs ModemCommEventArgs.eModemCommEvent.Connected)); } } Define the new EventArgs parameter: public class ModemCommEventArgs : EventArgs{ public enum eModemCommEvent { Idle, Connected, Disconnected, SendingData, ReceivingData } public eModemCommEvent eventType { get; set; } public string eventMessage { get; set; } public ModemCommEventArgs(eModemCommEvent eventType, string eventMessage) { this.eventMessage = eventMessage; this.eventType = eventType; } } I then create a handler for the event in the application: ModemComm comm = new ModemComm(); comm.ModemCommEvent += OnModemCommEvent; and private void OnModemCommEvent(object source, ModemCommEventArgs e) { } The problem is, I get a 'Object reference not set to an instance of an object' error when the object attempts to raise the event. Hoping someone can explain in n00b terms why and how to fix it :)

    Read the article

  • Approaches for Error Code/Message Management in .NET

    - by WayneC
    Looking for suggestions/best practices on managing error codes and messages in a multi-tiered applications. Specifically things like: Where should error codes be defined? Enum? Class? How are error messages or further details associated with the error codes? resource files? attributes on enum values, etc.? If you have a multi-tier application consisting of DAL, BLL, UI, and Common projects for example, should there be a single giant list of codes for all tiers, or are the codes extensible by project/tier? Update: Important to mention that I can't rely solely on Exceptions and custom Exception types for error reporting, as some clients for this application will be via web services (SOAP & REST) Any suggestions welcome!

    Read the article

  • keyUp event heard?: Overridden NSView method

    - by Old McStopher
    UPDATED: I'm now overriding the NSView keyUp method from a NSView subclass set to first responder like below, but am still not seeing evidence that it is being called. @implementation svsView - (BOOL)acceptsFirstResponder { return YES; } - (void)keyUp:(NSEvent *)event { //--do key up stuff-- NSLog(@"key up'd!"); } @end --ORIGINAL POST-- I'm new to Cocoa and Obj-C and am trying to do a (void)keyUp: from within the implementation of my controller class (which itself is of type NSController). I'm not sure if this is the right place to put it, though. I have a series of like buttons each set to a unique key equivalent (IB button attribute) and each calls my (IBAction)keyInput method which then passes the identity of each key onto another object. This runs just fine, but I also want to track when each key is released. --ORIGINAL [bad] EXAMPLE-- @implementation svsController //init //IBActions - (IBAction)keyInput:(id)sender { //--do key down stuff-- } - (void)keyUp:(NSEvent *)event { //--do key up stuff-- } @end Upon fail, I also tried the keyUp as an IBAction (instead of void), like the user-defined keyInput is, and hooked it up to the appropriate buttons in Interface Builder, but then keyUp was only called when the keys were down and not when released. (Which I kind of figured would happen.) Pardon my noobery, but should I be putting this method in another class or doing something differently? Wherever it is, though, I need it be able to access objects owned by the controller class. Thanks for any insight you may have.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >