Search Results

Search found 5259 results on 211 pages for 'interrupt handling'.

Page 41/211 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • Throw a long list of exceptions vs throw an Exception vs throw custom exception?

    - by athena
    I have an application which uses two methods of an API. Both these methods throw more than five exceptions each. So, if I just add a throws declaration then it becomes a list of more than ten. (My method cannot handle any of the ten exceptions) I have read that throwing a long list of exceptions is a bad practice. Also throwing (the umbrella) Exception is a bad practice. So, what should I do? Add a try catch block, and log and exit in the catch block? (Current approach) Create a custom exception class, wrap every exception and throw the custom exception? Add a throws declaration for all exceptions? Throw Exception?

    Read the article

  • Handling over-long UTF-8 sequences

    - by Grant McLean
    I've just been reworking my Encoding::FixLatin Perl module to handle over-long utf8 byte sequences and convert them to the shortest normal form. My question is quite simply "is this a bad idea"? A number of sources (including this RFC) suggest that any over-long utf8 should be treated as an error and rejected. They caution against "naive implementations" and leave me with the impression that these things are inherently unsafe. Since the whole purpose of my module is to clean up messy data files with mixed encodings and convert them to nice clean utf8, this seems like just one more thing I can clean up so the application layer doesn't have to deal with it. My code does not concern itself with any semantic meaning the resulting characters might have, it simply converts them into a normalised form. Am I missing something. Is there a hidden danger I haven't considered?

    Read the article

  • Extending Throwable in Java

    - by polygenelubricants
    Java lets you create an entirely new subtype of Throwable, e.g: public class FlyingPig extends Throwable { ... } Now, very rarely, I may do something like this: throw new FlyingPig("Oink!"); and of course elsewhere: try { ... } catch (FlyingPig porky) { ... } My questions are: Is this a bad idea? And if so, why? What could've been done to prevent this subtyping if it is a bad idea? Since it's not preventable (as far as I know), what catastrophies could result? If this isn't such a bad idea, why not? How can you make something useful out of the fact that you can extends Throwable?

    Read the article

  • jQuery Autocomplete & jTemplates - handling response

    - by Diegos Grace
    Has anyone had any experience with using jTemplates to display autocomplete results. I have the following $("#address-search").autocomplete({ source: "/Address/SearchAddress", minLength: 2, delay: 400, focus: function (event, ui) { $('#address-search').val(ui.item.name); return false; }, parse: function(data) { $("#autocomplete-results").setTemplate($("#templateHolder").html()); $("#autocomplete-results").processTemplate(data); }, select: function (event, ui) { $('#address-search').val(ui.item.name); $('#search-address-id').val(ui.item.id); $('#search-description').html(ui.item.address); }); and the simple jtemplate holder: <script type="text/html" id="templateHolder"> <ul class="autocomplete"> {#foreach $T as data} <li>{$T.name}</li> {#/for} </ul> </script> Above i'm using 'Parse' to format results, I've also tried the autocomplete result method but not having any luck so far. The only success I've had is by using the private method ._renderItem and formatting the data that way but we want to render the output using the jTemplate. Any advice appreciated.

    Read the article

  • Handling Special char such as ^ÛY, ^ÛR in java

    - by RJ
    Hi, Has anybody encountered special char such as ^ÛY, ^ÛR ? Q1. How do I do an ftp of the files containing these chars? The chars are not seen once I do a ftp on AIX (bi or ascii) and hence I am unable to see my program to replace these, working. Q2. My java program doesn't seem to recognise these or replace these if I search for these explicitly (^ÛY, ^ÛR ) in the file however a replace using regular expression seems to work (I could only see the difference in the length of the string). My program is executed on AIX. Any insights why java cannot recognise these? Q3. Does the Oracle database recognise these chars? An update is failing where my program indicates the string to be of lesser length and without these characters but the db complains "value too large for column" as the string to be updated contains these chars and hence longer. thanks in advance, RJ

    Read the article

  • need to get the context value in top of page, where the context value will be set only at the bottom

    - by Mahadevan Alagar
    <script runat="server"> protected void Page_Load(object sender, EventArgs e) { Response.Write("Page Load:"); } public string setContext(string sName, string sVal) { HttpContext.Current.Items[sName] = sVal; return sVal; } public string getContext(string sName) { string sVal = "default"; if (HttpContext.Current.Items[sName] != null) sVal = HttpContext.Current.Items[sName].ToString(); else sVal = "empty"; return sVal; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Get Context in TOP ???</title> </head> <body> <div> <div id="divDest" name="divDest"> Top Content: Get1 :<%= getContext("topcontent") %> // returns "empty", BUT I Need "value to set" </div> <br /> Set1 : <%= setContext("topcontent", "value to set")%> <br /> // set the value <br /> Get2 : <%= getContext("topcontent") %><br /> // returns "value to set" <br /> <script language="javascript"> var elval = getElementVal("divTest"); document.getElementById("divDest").innerHTML = elval; //alert(elval); function getElementVal(elemid) { var elemval = document.getElementById(elemid); return elemval.innerHTML; } </script> </body> </html> I need to get the context value in top of page, where the context value will be set at the bottom of the page. Get context value == "empty", BUT need "something" Set context value to "something" Get context value == "something" I may use JS/AJAX, where the page source the value won't be present. BUT I need the TEXT in the View Source of the page too. Is there a way to wait for the context to set and then get, I have tried with User Control, prerender and render methods too. But I can't able to get it right. Any idea?

    Read the article

  • Performing text processing on flatpage content to include handling of custom tag

    - by Dzejkob
    Hi. I'm using flatpages app in my project to manage some html content. That content will include images, so I've made a ContentImage model allowing user to upload images using admin panel. The user should then be able to include those images in content of the flatpages. He can of course do that by manually typing image url into <img> tag, but that's not what I'm looking for. To make including images more convenient, I'm thinking about something like this: User edits an additional, let's say pre_content field of CustomFlatPage model (I'm using custom flatpage model already) instead of defining <img> tags directly, he uses a custom tag, something like [img=...] where ... is name of the ContentImage instance now the hardest part: before CustomFlatPage is saved, pre_content field is checked for all [img=...] occurences and they are processed like this: ContentImage model is searched if there's image instance with given name and if so, [img=...] is replaced with proper <img> tag. flatpage actual content is filled with processed pre_content and then flatpage is saved (pre_content is leaved unchanged, as edited by user) The part that I can't cope with is text processing. Should I use regular expressions? Apparently they can be slow for large strings. And how to organize logic? I assume it's rather algorithmic question, but I'm not familliar with text processing in Python enough, to do it myself. Can somebody give me any clues?

    Read the article

  • controlling if exceptions are swallowed by a static boolean

    - by sandis
    So we are a few guys developing this product that is communicating with a really unstable server. It often returns very strange and corrupt data. During testing we want the resulting crashes to be loud, so we discover them. But every other day we need to demonstrate our product for a potential customer. To the customer the errors will go undiscovered if we just swallow them. I am thinking about implementing something like this around all server communication to quickly switch between swallowing exceptions and crashing: try { apiCall(); } catch (Exception e) { if(!SWALLOW_EXCEPTION) { throw e; } } Is this an awesome idea, or can it be done in a better way?

    Read the article

  • File Encoding handling in Eclipse 3.5

    - by Cédric Girard
    Hi, I use Eclipse 3.5 on Windows, with PDT and Subclipse plugins, with both legacy projects using ISO-8859-1 encoding (latin-1), and newers ones wich use UTF-8. I configured my workspace to use UTF-8, and I configured old projects to use latin-1. But every time I open an old project, it use UTF-8. With a workspace using latin-1 by default, I have the same problem with utf-8 projects edited as iso-8859-1. My encoding choice is written in the file .settings/org.eclipse.core.resources.prefs but seems to be never read. The only solution for now is to have a latin1 workspace, and an utf8 one. Any better idea? Regards, Cédric

    Read the article

  • Handling national language prefix for checkconstraints

    - by Chris Chilvers
    I'm trying to create a check constraint such as CHECK Type IN (N'Create', N'Remove') for an enumeration's value. Sqlite complains about this syntax and only accepts CHECK Type IN ('Create', 'Remove'). The main database will be Sql Server 2005, but I use sqlite's in memory database for unit tests. Is there any way to get sqlite to recognise the national language (N) prefix? Alternatively, is there an easy way when using FluentNHibernate to adapt an nvarchar constant to match the database's dialect?

    Read the article

  • Handling inverse kinematics: animation blending or math?

    - by meds
    I've been working for the past four days on inverse kinematics for my game engine. I'm working on a game with a shoestring budget so when the idea of inverse kinematics came up I knew I had to make it such that the 3D models bones would be mathematically changed to appear to be stepping on objects. This is causing some serious problems with my animation, after it was technically implemented the animations started looking quite bad when the character was wlaking up inclines or steps even though mathematically the stepping was correct and was even smoothly interpolating. So I was wondering, is it actually possible to get a smooth efficient inverse kinematic system based exclusively on math where bones are changed or is this just a wild goose chase and I should either solve the inverse kinematics problem with animation blending or don't do it at all?

    Read the article

  • ASP.NET MVC: Returning a view with querystring in tact

    - by ajbeaven
    I'm creating a messaging web app in ASP.NET and are having some problems when displaying an error message to the user if they go to send a message and there is something wrong. A user can look through profiles of people and then click, 'send a message'. The following action is called (url is /message/create?to=username) and shows them a page where they can enter their message and send it: public ActionResult Create(string to) { ViewData["recipientUsername"] = to; return View(); } On the page that is displayed, the username is entered in to a hidden input field. When the user clicks 'send': [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(string message, string to) { try { //do message stuff that errors out } catch { ModelState.AddModelErrors(message.GetRuleViolations()); //adding errors to modelstate } return View(); } So now the error message is displayed to the user fine, however the url is changed in that it no longer has the querystring (/message/create). Again, this would be fine except that when the user clicks the refresh button, the page errors out as the Create action no longer has the 'to' parameter. So I'm guessing that I need to maintain my querystring somehow. Is there any way to do this or do I need to use a different method altogether?

    Read the article

  • Use of FTP "append" command

    - by sahs
    I want to upload a file to a ftp server programmatically (C++). If the connection is lost while uploading a file, I wouldn't want to upload the file from scratch, but to upload only the part that I haven't sent. Does the APPE command fulfill my demand? What list of FTP commands should I use exactly? And how?

    Read the article

  • skip-limit ignored for skippable exception thrown from writer

    - by ck
    i am working on a project with spring batch 2.0.2 and have skippable exception set up in the config. for exceptions thrown from the processor everything works fine. it skips and once the limit is execeed the job fails (or stops). for exceptions thrown from the writer (same chunk) it keeps skipping. the skip-limit doesnt seem to matter. maybe i missunderstood and skipping and writer don't go together or maybe i am missing a configuration. does anyone know how to skip issues - with a limit - within the writer properly?

    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

  • Unhandled Exception in c#

    - by nightcoder1
    Hello i am currently trying to run a web crawler through the terminal. it compiles fine and the debug does not find any errors, however i get the following error which i do not understand. any ideas on how to get rid of this error would be much appreciated Unhandled Exception: System.ArgumentOutOfRangeException: startIndex + length > this.length Parameter name: length at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] at OpenWebSpiderCS.mysql.executeSQLQuery (System.String SQL) [0x00000] at OpenWebSpiderCS.db.startIndexThisSite (OpenWebSpiderCS.page p) [0x00000] at OpenWebSpiderCS.ows.startCrawling () [0x00000] at OpenWebSpiderCS.mainClass.Main (System.String[] args) [0x00000] thank you

    Read the article

  • PHP autoloader: ignoring non-existing include

    - by Bart van Heukelom
    I have a problem with my autoloader: public function loadClass($className) { $file = str_replace(array('_', '\\'), '/', $className) . '.php'; include_once $file; } As you can see, it's quite simple. I just deduce the filename of the class and try to include it. I have a problem though; I get an exception when trying to load a non-existing class (because I have an error handler which throws exceptions). This is inconvenient, because it's also fired when you use class_exists() on a non-existing class. You don't want an exception there, just a "false" returned. I fixed this earlier by putting an @ before the include (supressing all errors). The big drawback with this, though, is that any parser/compiler errors (that are fatal) in this include won't show up (not even in the logs), resulting in a hard to find bug. What would be the best way to solve both problems at once? The easiest way would be to include something like this in the autoloader (pseudocode): foreach (path in the include_path) { if (is_readable(the path + the class name)) readable = true; } if (!readable) return; But I worry about the performance there. Would it hurt a lot? (Solved) Made it like this: public function loadClass($className) { $file = str_replace(array('_', '\\'), '/', $className) . '.php'; $paths = explode(PATH_SEPARATOR, get_include_path()); foreach ($paths as $path) { if (is_readable($path . '/' . $file)) { include_once $file; return; } } }

    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

  • Call a function when "event.GetFrom(m_cpVoice)==S_OK" (ergo when event happens) [SAPI 5.1 and C++]

    - by Jesuskiewicz
    Hello, I'm doing a project with a 3D model, that speaks. So, I'm using SAPI 5.1, and I want to call a function asynchronously when there's a Viseme event (in order to play the animation related to). How could I do it? Thank you very much. Note: I use : hRes = m_cpVoice-Speak(L"All I want is to solve this problem", SPF_ASYNC , NULL); And I know the CspEvent, event.eEventId . All I want is how to call a function when Sapi event happens

    Read the article

  • Graceful handling of server timeout in BlazeDS

    - by Rydell
    I have a flex client that makes service calls to a tomcat server running BlazeDS. I would like to gracefully handle server session timeouts in this environment. I do have security constraints on the service, so the client authenticates against a remote object by initializing a ChannelSet based on the destination, and then logging in using that ChannelSet. After the user is authenticated, if they go get a (long) cup of coffee, their session will inevitably time out. I would like the client to detect the timeout, and return the user back to the login page, with the appropriate informational messages. But I am having difficulty finding the best way to detect this timeout from the client. Is it possible, or must I have the server throw an error when the timeout occurs? Thanks!

    Read the article

  • Writing catch block with cleanup operations in Java ...

    - by kedarmhaswade
    I was not able to find any advise on catch blocks in Java that involve some cleanup operations which themselves could throw exceptions. The classic example is that of stream.close() which we usually call in the finally clause and if that throws an exception, we either ignore it by calling it in a try-catch block or declare it to be rethrown. But in general, how do I handle cases like: public void doIt() throws ApiException { //ApiException is my "higher level" exception try { doLower(); } catch(Exception le) { doCleanup(); //this throws exception too which I can't communicate to caller throw new ApiException(le); } } I could do: catch(Exception le) { try { doCleanup(); } catch(Exception e) { //ignore? //log? } throw new ApiException(le); //I must throw le } But that means I will have to do some log analysis to understand why cleanup failed. If I did: catch(Exception le) { try { doCleanup(); } catch(Exception e) { throw new ApiException(e); } It results in losing the le that got me here in the catch block in the fist place. What are some of the idioms people use here? Declare the lower level exceptions in throws clause? Ignore the exceptions during cleanup operation?

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >