Search Results

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

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

  • PHP DOMDocument Error Handling Problem

    - by Jon
    I'm having trouble trying to write an if statement for DOM that will check if $html is blank. However whenever the html page does end up blank, it just removes everything that would be below DOM (including what I had to check if it was blank). $html = file_get_contents("http://example.com/"); $dom = new DOMDocument; @$dom->loadHTML($html); $links = $dom->getElementById('dividhere')->getElementsByTagName('img'); foreach ($links as $link) { echo $link->getAttribute('src'); } All this does is grab an image url in the specified div, which works perfectly until the page is a blank html page. I've tried using SimpleHTMLDOM, which didn't work either (it didn't even fetch the image on working pages). Did I happen to miss something with this one or am I just missing something in both? include_once('simple_html_dom.php') $html = file_get_html("http://example.com/"); foreach($html->find('div[id="dividhere"]') as $div) { if(empty($div->src)) { continue; } echo $div->src; }

    Read the article

  • SSIS Handling Extenal Issues

    - by durilai
    I have an SSIS package that works fine. The package runs every night and takes about 4 hours to complete. I have am a newb to SSIS, so I want to see what my options are. I am not finding anything on the web about these two issues, so any advice is greatly appreciated. What to do when I have an external issue such as a power failure/accidental restart. Is there a way to alert someone or have the package begin again on restart. A couple weeks ago there was a process that got hung and locked table, making the process not execute. How is the best way to handle ensuring I have the proper access before starting and if not, get the access. I am ok with killing the processes etc. Looking for best practice info. Thanks

    Read the article

  • JavaScript Exception/Error Handling Not Working

    - by Seán Hayes
    This might be a little hard to follow. I've got a function inside an object: f_openFRHandler: function(input) { console.debug('f_openFRHandler'); try{ //throw 'foo'; DragDrop.FileChanged(input); //foxyface.window.close(); } catch(e){ console.error(e); jQuery('#foxyface_open_errors').append('<div>Max local storage limit reached, unable to store new images in your browser. Please remove some images and try again.</div>'); } }, inside the try block it calls: this.FileChanged = function(input) { // FileUploadManager.addFileInput(input); console.debug(input); var files = input.files; for (var i = 0; i < files.length; i++) { var file = files[i]; if (!file.type.match(/image.*/)) continue; var reader = new FileReader(); reader.onload = (function(f, isLast) { return function(e) { if (files.length == 1) { LocalStorageManager.addImage(f.name, e.target.result, false, true); LocalStorageManager.loadCurrentImage(); //foxyface.window.close(); } else { FileUploadManager.addFileData(f, e.target.result); // add multiple files to list if (isLast) setTimeout(function() { LocalStorageManager.loadCurrentImage() },100); } }; })(file, i == files.length - 1); reader.readAsDataURL(file); } return true; LocalStorageManager.addImage calls: this.setItem = function(data){ localStorage.setItem('ImageStore', $.json_encode(data)); } localStorage.setItem throws an error if too much local storage has been used. I want to catch that error in f_openFRHandler (first code sample), but it's being sent to the error console instead of the catch block. I tried the following code in my Firebug console to make sure I'm not crazy and it works as expected despite many levels of function nesting: try{ (function(){ (function(){ throw 'foo' })() })() } catch(e){ console.debug(e) } Any ideas?

    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

  • 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

  • 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

  • Avoid throwing a new exception

    - by GustlyWind
    I have an if condition which checks for value and the it throws new NumberFormatException Is there any other way to code this if (foo) { throw new NumberFormatException } // .. catch (NumberFormatException exc) { // some msg... }

    Read the article

  • Should the PHP community start using more descriptive 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

  • 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

  • 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

  • need an empty string, but getting an exception in ruby on rails

    - by Jon
    controller @articles = current_user.articles view <% @articles.each do |article| %> <%= link_to "#{article.title} , #{article.author.name}" articles_path%> <% end %> Sometimes the article has no author, so is null in the database, which results in the following error You have a nil object when you didn't expect it! The error occurred while evaluating nil.name I still want to output the article title in this scenario, whats the best way to do this please?

    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

  • PostgreSQL pgdb driver raises "can't rollback" exception

    - by David Parunakian
    Hello, for some reason I'm experiencing the Operational Error with "can't rollback" message when I attempt to roll back my transaction in the following context: try: cursors[instance].execute("lock revision, app, timeout IN SHARE MODE") cursors[instance].execute("insert into app (type, active, active_revision, contents, z) values ('session', true, %s, %s, 0) returning id", (cRevision, sessionId)) sAppId = cursors[instance].fetchone()[0] cursors[instance].execute("insert into revision (app_id, type) values (%s, 'active')", (sAppId,)) cursors[instance].execute("insert into timeout (app_id, last_seen) values (%s, now())", (sAppId,)) connections[instance].commit() except pgdb.DatabaseError, e: connections[instance].rollback() return "{status: 'error', errno:4, errmsg: \"%s\"}"%(str(e).replace('\"', '\\"').replace('\n', '\\n').replace('\r', '\\r')) The driver in use is PGDB. What is fundamentally wrong here?

    Read the article

  • C++ wxWidgets Event (Focus) Handling

    - by Wallter
    Due to comments I added the following code (in BasicPanel) Connect(CTRL_ONE, wxEVT_KILL_FOCUS, (wxObjectEventFunction)&BasicPanel::OnKillFocus); Connect(CTRL_TWO,wxEVT_KILL_FOCUS, (wxObjectEventFunction)&BasicPanel::OnKillFocus); Connect(CTRL_THREE, wxEVT_KILL_FOCUS, (wxObjectEventFunction)&BasicPanel::OnKillFocus); Connect(CTRL_FOUR, wxEVT_KILL_FOCUS, (wxObjectEventFunction)&BasicPanel::OnKillFocus); Connect(CTRL_FIVE, wxEVT_KILL_FOCUS, (wxObjectEventFunction)&BasicPanel::OnKillFocus); (enums) CTRL_NAME = wxID_HIGHEST + 5, // 6004 CTRL_ADDRESS = wxID_HIGHEST + 6, // 6005 CTRL_PHONENUMBER = wxID_HIGHEST + 7, // 6006 CTRL_SS = wxID_HIGHEST + 8, // 6007 CTRL_EMPNUMBER = wxID_HIGHEST + 9 // 6008 (The OnKillFocus Function - the declaration is included as suggested) void BasicPanel::OnKillFocus(wxFocusEvent& event) { switch (event.GetId()) { case 6004: ... break; ... ... ... } All of these added to the code do nothing when the user changes focus on which text box they are using... 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

  • rails delete_all exception

    - by Sergei
    Hello, guys! I have some User model, Role model and Assignment model to manage role-based user system. Just like here . So, here some kind of code, to include roles into users form: <% for role in Role.all %> <%= check_box_tag "user[role_ids][]", role.id, @user.roles.include?(role) %> <%=h role.name %><br /> <% end %> And all's working fine for new records and for editing records. But I just want to make possible to restrict deleting Assigment with id=1, cause this Assignment for default root user from migration, who must be admin anyway. Otherwise, I can lose my last admin. So I've tryed to add before_destroy to Assignment.rb model, but it doesn't work. I've noticed, that when I'm editing user and trying to remove his admin role(assignment), the server makes a delete_all method, not destroy method. So, does anybody know how to catch the deleting of Assignment with id=1 through this kind of code? Thanks in advance!

    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

  • Difference between Resume and Goto in error handling block

    - by Rich Oliver
    I understand that in the following example a Resume statement should be used instead of a Goto statement. Sub Method() On Error Goto ErrorHandler ... CleanUp: ... Exit Function ErrorHandler: Log error etc Err.Clear 'Is this line actually necessary?' Resume CleanUp 'SHOULD USE THIS' Goto CleanUp 'SHOULD NOT USE THIS' End Sub My question is what difference is there in the execution of the two?

    Read the article

  • Error & status handling for functions

    - by Industrial
    Hi everyone, We're working with a new codeigniter based application that are cross referencing different PHP functions forwards and backwards from various libraries, models and such. We're running PHP5 on the server and we try to find a good way for managing errors and status reports that arises from the usage of our functions. While using return in functions, the execution is ended, so nothing more can be sent back. Right? What's the best practice to send a status information or error code upon ending execution of actual function? Should we look into using exceptions or any other approach? http://us.php.net/manual/en/language.exceptions.php

    Read the article

  • Android NDK R5 and support of C++ exception

    - by plaisthos
    Hi, I am trying to use the NDK 5 full C++ gnustl: sources/cxx-stl/gnu-libstdc++/README states: This implementation fully supports C++ exceptions and RTTI. But all attempts using exceptions fail. An alternative NDK exists on http://www.crystax.net/android/ndk-r4.php. Even the hello-jni example from that site does not work. Compliation works after creating an Application.xml with APP_STL := gnustl_static But it dies the same horrific death as my own experiments. Am I am missing something or is the statement in the README just plain wrong?

    Read the article

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