Search Results

Search found 36003 results on 1441 pages for 'try catch'.

Page 10/1441 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • how to catch ajax query post error?

    - by TTCG
    I would like to catch the error and show the appropriate message if the ajax request fails. My code is like the following, but I could not manage to catch the failure ajax request. function getAjaxData(id) { $.post("status.ajax.php", {deviceId : id}, function(data){ var tab1; if (data.length>0) { tab1 = data; } else { tab1 = "Error in Ajax"; } return tab1; }); } I found out that, "Error in Ajax" is never executed when the Ajax request failed. How to handle the ajax error and show the appropriate message if it fails? Thanks very much.

    Read the article

  • ComboBox.SelectionChanged doesn't catch the first selection

    - by trnTash
    I need to fill textboxes depending on the item selected in a combobox. I fill combo async and in Completed event I have the following code combo.ItemsSource = e.Result; combo.DisplayMemberPath = "Name"; combo.SelectedIndex = -1; Then in the SelectionChanged event of the combo, I catch the selected object MyClass mc= ((ComboBox)sender).SelectedItem as MyClass; tbxName.Text = mc.Name; ... However, when I load the project and select any event for the 1st time, NOTHING happens. Every other time (2nd, 3rd, nth) the data is correctly caught and displayed. So I need to know why the combo doesn't catch the first selection? That's the reason I have the code combo.SelectedIndex = -1 (when the app loads, combo is empty - selection -1 works).

    Read the article

  • Using ClaimsPrincipalPermissionAttribute, how do I catch the SecurityException?

    - by Ryan Roark
    In my MVC application I have a Controller Action that Deletes a customer, which I'm applying Claims Based Authorization to using WIF. Problem: if someone doesn't have access they see an exception in the browser (complete with stacktrace), but I'd rather just redirect them. This works and allows me to redirect: public ActionResult Delete(int id) { try { ClaimsPrincipalPermission.CheckAccess("Customer", "Delete"); _supplier.Delete(id); return RedirectToAction("List"); } catch (SecurityException ex) { return RedirectToAction("NotAuthorized", "Account"); } } This works but throws a SecurityException I don't know how to catch (when the user is not authorized): [ClaimsPrincipalPermission(SecurityAction.Demand, Operation = "Delete", Resource = "Customer")] public ActionResult Delete(int id) { _supplier.Delete(id); return RedirectToAction("List"); } I'd like to use the declarative approach, but not sure how to handle unauthorized requests. Any suggestions?

    Read the article

  • Check For Duplicate Records VS try/catch Unique Key Constraint

    - by Jed
    I have a database table that has a Unique Key constraint defined to avoid duplicate records from occurring. I'm curious if it is bad practice to NOT manually check for duplicate records prior to running an INSERT statement on the table. In other words, should I run a SELECT statement using a WHERE clause that checks for duplicate values of the record that I am about to INSERT. If a record is found, then do not run the INSERT statement, otherwise go ahead and run the INSERT.... OR Just run the INSERT statement and try/catch the exception that may be thrown due to a Unique Key violation. I'm weighing the two perspectives and can't decide which is best- 1. Don't waste a SELECT call to check for duplicates when I can just trap for an exception VS 2. Don't be lazy by implementing ugly try/catch logic VS 3. ???Your thoughts here??? :)

    Read the article

  • How to catch mousewheel up/down event using RaphaelJs

    - by alex.dominte
    I need to implement a horizontal scrollable timeline. I've drawn the timeline/grids/rulers etc. I just need to catch mousewheel up/down to scroll the timeline (backward - past/forward - future). First I need to catch the event: but nothing I've found seems to work. Need browser support only for chrome/firefox (latest versions). These 2 won't listeners won't work: var paper = new Raphael('raphael-paper'); // ... paper.canvas.on('mousewheel', function(event) { console.log(event); }); // ... paper.canvas.addEventListener('mousewheel', function(event) { console.log(event); });

    Read the article

  • Catch PyGTK TreeView reorder

    - by mkotechno
    I have a simple gtk.TreeView with a gtk.ListStore model and set_reorderable(True), I want to catch the signal/event emited when the user reorder through drag&drop the list, but the documentation does not help much: "The application can listen to these changes by connecting to the model's signals" So I tried to connect the model (ListStore) signals... but surprise! ListStore has no signals, so you are dispatched to TreeModel signals, then I tried to connect with the TreeModel "rows-reordered" signal with no lucky. How should I catch the list reorder performed by the user?

    Read the article

  • Should I catch exceptions thrown when closing java.sql.Connection

    - by jb
    Connection.close() may throw SqlException, but I have always assumed that it is safe to ignore any such exceptions (and I have never seen code that does not ignore them). Normally I would write: try{ connection.close(); }catch(Exception e) {} Or try{ connection.close(); }catch(Exception e) { logger.log(e.getMessage(), e); } The question is: Is it bad practice (and has anyone had problems when ignoring such exeptions). When Connection.close() does throw any exception. If it is bad how should I handle the exception. Comment: I know that discarding exceptions is evil, but I'm reffering only to exceptions thrown when closing a connection (and as I've seen this is fairly common in this case). Does anyone know when Connection.close() may throw anything?

    Read the article

  • How to catch specific exception without error number?

    - by CJ7
    I need to catch the following specific exception: System.Data.OleDb.OleDbException was caught ErrorCode=-2147467259 Message="The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again." Source="Microsoft JET Database Engine" I'm not sure what ErrorCode is but it looks unreliable. Can I rely on Message being identical across platforms? Is the only solution to do a text search of Message for words like duplicate and primary key? Note: see my question here for why I need to catch this exception.

    Read the article

  • C# - Rollback SqlTransaction in catch block - Problem with object accessability

    - by Marks
    Hi there. I've got a problem, and all articles or examples i found seem to not care about it. I want to do some database actions in a transaction. What i want to do is very similar to most examples: using (SqlConnection Conn = new SqlConnection(_ConnectionString)) { try { Conn.Open(); SqlTransaction Trans = Conn.BeginTransaction(); using (SqlCommand Com = new SqlCommand(ComText, Conn)) { /* DB work */ } } catch (Exception Ex) { Trans.Rollback(); return -1; } } But the problem is, that the SqlTransaction Trans is declared inside the try block. So it is not accessable in the catch() block. Most examples just do Conn.Open() and Conn.BeginTransaction() before the try block. But i think thats a bit risky, since both can throw multiple exceptions. Am I wrong, or do most people just ignore this risk? Whats the best solution to be able to rollback, if an exception happens. Thanks in advance, Marks

    Read the article

  • How to properly catch a 404 error in .NET

    - by Luke101
    I would like to know the proper way to catch a 404 error with c# asp.net here is the code I'm using HttpWebRequest request = (HttpWebRequest) WebRequest.Create(String.Format("http://www.gravatar.com/avatar/{0}?d=404", hashe)); // execute the request try { //TODO: test for good connectivity first //So it will not update the whole database with bad avatars HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Response.Write("has avatar"); } catch (Exception ex) { if (ex.ToString().Contains("404")) { Response.Write("No avatar"); } } This code works but I just would like to know if this is the most efficient.

    Read the article

  • iphone dev - how to catch exception 'NSRangeException'

    - by Brian
    In my app I try to scroll a UITableView to the top once after I updated the content of the table. However, under some circumstance, my table is EMPTY. So I got the following exception: Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:]: row (0) beyond bounds (0) for section (0).' how can I catch this exception? I tried NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; if (indexPath != nil) { [EventTable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; } but it doesn't catch the exception because indexPath is not nil.

    Read the article

  • Catch Commandline error

    - by Bi
    Hi I am trying to catch an error with an incorrect commandline parameter for the application of form Myapp.exe myFile.txt The application however throws an "Unhandled exception - The path is not of legal form". Below is my code and I am wondering why it does not show the message box as provided in the code? Thanks. String[] cmdlineArgs = Environment.GetCommandLineArgs(); if (cmdlineArgs.Length == 2) { try { if (File.Exists(cmdlineArgs[1].ToString())) ConfigParameters.SetConfigParameters(cmdlineArgs[1].ToString()); else { MessageBox.Show("Configuration file does not exist.Restarting..."); Environment.Exit(1); } } catch (Exception ex) { }

    Read the article

  • Using a message class static method taking in an action to wrap Try/Catch

    - by Chris Marisic
    I have a Result object that lets me pass around a List of event messages and I can check whether an action was successful or not. I've realized I've written this code in alot of places Result result; try { //Do Something ... //New result is automatically a success for not having any errors in it result = new Result(); } catch (Exception exception) { //Extension method that returns a Result from the exception result = exception.ToResult(); } if(result.Success) .... What I'm considering is replacing this usage with public static Result CatchException(Action action) { try { action(); return new Result(); } catch (Exception exception) { return exception.ToResult(); } } And then use it like var result = Result.CatchException(() => _model.Save(something)); Does anyone feel there's anything wrong with this or that I'm trading reusability for obscurity?

    Read the article

  • exchange server 2010 with multiple domains

    - by air
    i have one exchange server 2010, which is working fine with one domain. my exchange is working as follows pop3 collector collect emails from one master catchall account and then deliver to exchange server, this working perfect. now what i want to add another domain to same exchange, i have added new domain as trusted domain & email policy and this new domain email account works fine with internal emails. now what i have done, i again forward new email account to same catchall account. but if i send email from any other external email address email is bounce, i can see email receive by pop3 collector but bounce by exchange server. to make you more clear let me explain logic on which i am working. i have 2 domains 1. domain1.com ([email protected]) 2. domain2.com ([email protected] -->[email protected]) now on my machine with exchange server i have pop3 collector which collect all emails from [email protected] and forward to exchange 2010 server. all emails to domain1.com is working perfect but when i send email to [email protected] this email redirect to [email protected] perfectly but when exchanger server receive this email, it bounce. i have also study the url link text and follow the whole process but no success. i also check that my DNS/MX is working fine as the bounce message is going from my exchange server. EDIT the only problem is with accepted domain, as email come to exchange server then bounce back. i just try this today i create one user called test, then i goto his properties -- email there was only one email account [email protected] i try to send email to [email protected] from internet (email bounce) then again i go to test user properties -- email and Add one email [email protected] again u try to send email to t*[email protected]* from internet (email received) i think the only problem is with accepted domain but in hub transport , it shows accepted is there any way to check does domain is properly accepted or not in exchange 2010 server. Thanks

    Read the article

  • Does 'throw' or 'try...catch' hinder performance?

    - by Richard
    I've been reading all over the place (including here) about when exception should / shouldn't be used. I now want to change my code that would throw to make the method return false and handle it like that, but my question is: Is it the throwing or try..catch-ing that can hinder performance...? What I mean is, would this be acceptable: bool method someMmethod() { try { // ...Do something catch (Exception ex) // Don't care too much what at the moment... { // Output error // Return false } return true // No errors Or would there be a better way to do it? (I'm bloody sick of seeing "Unhandled exception..." LOL!)

    Read the article

  • PHP Try and Catch for SQL Insert

    - by meme
    I have a page on my website (high traffic) that does an insert on every page load. I am curious of the fastest and safest way to (catch an error) and continue if the system is not able to do the insert into MySQL. Should I use try/catch or die or something else. I want to make sure the insert happens but if for some reason it can't I want the page to continue to load anyway. ... $db = mysql_select_db('mobile', $conn); mysql_query("INSERT INTO redirects SET ua_string = '$ua_string'") or die('Error #10'); mysql_close($conn); ...

    Read the article

  • Does everything after my try statement have to be encompassed in that try statement to access variab

    - by Mithrax
    I'm learning java and one thing I've found that I don't like, is generally when I have code like this: import java.util.*; import java.io.*; public class GraphProblem { public static void main(String[] args) { if (args.length < 2) { System.out.println("Error: Please specify a graph file!"); return; } FileReader in = new FileReader(args[1]); Scanner input = new Scanner(in); int size = input.nextInt(); WeightedGraph graph = new WeightedGraph(size); for(int i = 0; i < size; i++) { graph.setLabel(i,Character.toString((char)('A' + i))); } for(int i = 0; i < size; i++) { for(int j = 0; j < size; j++) { graph.addEdge(i, j, input.nextInt()); } } // .. lots more code } } I have an uncaught exception around my FileReader. So, I have to wrap it in a try-catch to catch that specific exception. My question is does that try { } have to encompass everything after that in my method that wants to use either my FileReader (in) or my Scanner (input)? If I don't wrap the whole remainder of the program in that try statement, then anything outside of it can't access the in/input because it may of not been initialized or has been initialized outside of its scope. So I can't isolate the try-catch to just say the portion that intializes the FileReader and close the try statement immediately after that. So, is it the "best practice" to have the try statement wrapping all portions of the code that are going to access variables initialized in it? Thanks!

    Read the article

  • Need assistance with Kohana 3 and catch all route turning into a 404 error

    - by alex
    Based on this documentation, I've implemented a catch all route which routes to an error page. Here is the last route in my bootstrap.php Route::set('default', '<path>', array('path' => '.+')) ->defaults(array( 'controller' => 'errors', 'action' => '404', )); However I keep getting this exception thrown when I try and go to a non existent page Kohana_Exception [ 0 ]: Required route parameter not passed: path If I make the <path> segment optional (i.e. wrap it in parenthesis) then it just seems to load the home route, which is... Route::set('home', '') ->defaults(array( 'controller' => 'home', 'action' => 'index', )); The home route is defined first. I execute my main request like so $request = Request::instance(); try { // Attempt to execute the response $request->execute(); } catch (Exception $e) { if (Kohana::$environment === Kohana::DEVELOPMENT) throw $e; // Log the error Kohana::$log->add(Kohana::ERROR, Kohana::exception_text($e)); // Create a 404 response $request->status = 404; $request->response = Request::factory(Route::get('default')->uri())->execute(); } $request->send_headers(); echo $request->response; This means that the 404 header is sent to the browser, but I assumed by sending the request to the capture all route then it should show the 404 error set up in my errors controller. <?php defined('SYSPATH') or die('No direct script access.'); class Controller_Errors extends Controller_Base { public function before() { parent::before(); } public function action_404() { $this->bodyClass[] = '404'; $this->internalView = View::factory('internal/not_found'); $longTitle = 'Page Not Found'; $this->titlePrefix = $longTitle; } } Why won't it show my 404 error page?

    Read the article

  • PHP: Exception not caught by try ... catch

    - by Christian Brenner
    I currently am working on an autoloader class for one of my projects. Below is the code for the controller library: public static function includeFileContainingClass($classname) { $classname_rectified = str_replace(__NAMESPACE__.'\\', '', $classname); $controller_path = ENVIRONMENT_DIRECTROY_CONTROLLERS.strtolower($classname_rectified).'.controller.php'; if (file_exists($controller_path)) { include $controller_path; return true; } else { // TODO: Implement gettext('MSG_FILE_CONTROLLER_NOTFOUND') throw new Exception('File '.strtolower($classname_rectified).'.controller.php not found.'); return false; } } And here's the code of the file I try to invoke the autoloader on: try { spl_autoload_register(__NAMESPACE__.'\\Controller::includeFileContainingClass'); } catch (Exception $malfunction) { die($malfunction->getMessage()); } // TESTING ONLY $test = new Testing(); When I try to force a malfunction, I get the following message: Fatal error: Uncaught exception 'Exception' with message 'File testing.controller.php not found.' in D:\cerophine-0.0.1-alpha1\application\libraries\controller.library.php:51 Stack trace: #0 [internal function]: application\Controller::includeFileContainingClass('application\Tes...') #1 D:\cerophine-0.0.1-alpha1\index.php(58): spl_autoload_call('application\Tes...') #2 {main} thrown in D:\cerophine-0.0.1-alpha1\application\libraries\controller.library.php on line 51 What seems to be wrong?

    Read the article

  • Check if file is locked or catch error for trying to open

    - by Duncan Matheson
    I'm trying to handle the problem where a user can try to open, with an OpenFileDialog, a file that is open by Excel. Using the simple FileInfo.OpenRead(), it chucks an IOException, "The process cannot access the file 'cakes.xls' because it is being used by another process." This would be fine to display to the user except that the user will actually get "Debugging resource strings are unavailable" nonsense. It seems not possible to open a file that is open by another process, since using FileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite) chucks a SecurityException, "File operation not permitted. Access to path 'C:\whatever\cakes.xls' is denied.", for any file. Rather unhelpful. So it's down to either finding some way of checking if the file is locked, or trying to catch the IOException. I don't want to catch all IOExceptions and assume they're all locked file errors, so I need some sort of way of classifying this type of exception as this error... but the "Debugging resource strings" nonsense along with the fact that that message itself is probably localized makes it tricky. I'm partial trust, so I can't use Marshal.GetHRForException. So: Is there any sensible way of either check if a file is locked, or at least determining if this problem occurred without just catching all IOExceptions?

    Read the article

  • Windows crashes when I try to compress large .MOV file from iPhone

    - by Andrew
    I have a 40 minute, 6 gigabyte .MOV file that I transferred from my iPhone to my PC. I need to upload the video to Youtube but the file is too large. When I try to compress the video, my computer will shut off when the process reaches 3 or 4 percent. This has happened in Windows Live Movie Maker, Riva FLV encoder, and VLC. Any ideas on how I can get this file down to a reasonable size so I can upload it online?

    Read the article

  • Firefox or IE crashes when I try to print

    - by Vidar
    When I try to print a web page in either IE or Firefox - it just crashes? Any ideas? Printer works with other applications fine - like Word etc. It's only browser related for some strange reason. I am running XP SP3 - the printer is a Canon Laser Shot LBP 1120

    Read the article

  • What's the difference between the code inside a finally clause and the code located after catch clause?

    - by facebook-100005613813158
    My java code is just like below: public void check()throws MissingParamException{ ...... } public static void main(){ PrintWriter out = response.getWriter(); try { check(); } catch (MissingParamException e) { // TODO Auto-generated catch block out.println("message:"+e.getMessage()); e.printStackTrace(); out.close(); }finally{ out.close(); } //out.close(); } Then, my confusion is: what the difference if I put out.close() in a finally code block or if I just remove finally code block and put out.close() behind catch clause (which has been commented in the code). I know that in both ways, the out.close() will be executed because I know that whether the exception happened, the code behind the catch clause will always be executed.

    Read the article

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