Search Results

Search found 4116 results on 165 pages for 'baron throw'.

Page 1/165 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • java : how to handle the design when template methods throw exception when overrided method not throw

    - by jiafu
    when coding. try to solve the puzzle: how to design the class/methods when InputStreamDigestComputor throw IOException? It seems we can't use this degisn structure due to the template method throw exception but overrided method not throw it. but if change the overrided method to throw it, will cause other subclass both throw it. So can any good suggestion for this case? abstract class DigestComputor{ String compute(DigestAlgorithm algorithm){ MessageDigest instance; try { instance = MessageDigest.getInstance(algorithm.toString()); updateMessageDigest(instance); return hex(instance.digest()); } catch (NoSuchAlgorithmException e) { LOG.error(e.getMessage(), e); throw new UnsupportedOperationException(e.getMessage(), e); } } abstract void updateMessageDigest(MessageDigest instance); } class ByteBufferDigestComputor extends DigestComputor{ private final ByteBuffer byteBuffer; public ByteBufferDigestComputor(ByteBuffer byteBuffer) { super(); this.byteBuffer = byteBuffer; } @Override void updateMessageDigest(MessageDigest instance) { instance.update(byteBuffer); } } class InputStreamDigestComputor extends DigestComputor{ // this place has error. due to exception. if I change the overrided method to throw it. evey caller will handle the exception. but @Override void updateMessageDigest(MessageDigest instance) { throw new IOException(); } }

    Read the article

  • To Throw or Not to Throw

    - by serhio
    // To Throw void PrintType(object obj) { if(obj == null) { throw new ArgumentNullException("obj") } Console.WriteLine(obj.GetType().Name); } // Not to Throw void PrintType(object obj) { if(obj != null) { Console.WriteLine(obj.GetType().Name); } } What principle to keep? Personally Personally I prefer the first one its say developer-friendly. The second one its say user-friendly. What do you think?

    Read the article

  • Tutoriel Web Services Java : Décrire et configurer avec WSDL, par Mickael Baron

    Je continue la série de supports de cours concernant les Web Services via la plateforme Java. Ce deuxième support de cours vise à présenter le langage de description WSDL. Il permet de décrire le contrat d'un service Web. Cette présentation est très syntaxique. J'insiste sur la séparation de la partie description (abstraite) de la partie configuration (concrète). Si vous avez des commentaires, des souhaits, n'hésitez pas, profitez de cette discussion. Le cours : http://mbaron.developpez.com/soa/wsdl/ Mickael BARON (http://keulkeul.blogspot.com)...

    Read the article

  • throw exception

    - by Unknown
    Why can't you throw an InterruptedException in the following way: try { System.in.wait(5) //Just an example } catch (InterruptedException exception) { exception.printStackTrace(); //On this next line I am confused as to why it will not let me throw the exception throw exception; } I went to http://java24hours.com, but it didn't tell me why I couldn't throw an InterruptedException. If anyone knows why, PLEASE tell me! I'm desperate! :S

    Read the article

  • Tutoriel Java Web : Développer des Web Services étendus avec JAX-WS en Java, par Mickael Baron

    Une présentation générale de la spécification JAX-WS est donnée en première partie. Le développement de web services côté serveur est ensuite abordé via deux points de vue (approche montante et approche descendante). Il est suivi d'une partie expliquant comment utiliser JAX-WS dans un client pour appeler un web service étendu. Les parties suivantes s'intéressent à décrire les annotations, le mécanisme d'intercepteur (handler) et l'utilisation de JAX-WS via Java SE 6 et via les EJBs.

    Read the article

  • Tutoriel Eclipse : Atelier Construction Plug-in : les commandes, par Mickaël Baron

    Bonjour, Je vous propose de continuer la série d'articles intitulée Atelier "Construction Plug-in avec la plateforme Eclipse". L'objectif pour rappel est de fournir des tutoriels très détaillés sur la manière de développer des plug-ins Eclipse. Vous trouverez par le biais de ces articles un complément aux différents supports de cours déjà rédigés sur le plateforme Eclipse (http://mbaron.developpez.com/) Le but de cette quatrième leçon est d'apprendre à ajouter des commandes puis à appliquer des restrictions sur l'affichage et le comportement de ces commandes. Cette leçon est divisée en deux exercices : Ajouter des commandes dans la barre de menu et la b...

    Read the article

  • throw new exception- C#

    - by Jalpesh P. Vadgama
    This post will be in response to my older post throw vs. throw(ex) best practice and difference- c# comment that I should include throw new exception. What’s wrong with throw new exception: Throw new exception is even worse, It will create a new exception and will erase all the earlier exception data. So it will erase stack trace also.Please go through following code. It’s same earlier post the only difference is throw new exception.   using System; namespace Oops { class Program { static void Main(string[] args) { try { DevideByZero(10); } catch (Exception exception) { throw new Exception (string.Format( "Brand new Exception-Old Message:{0}", exception.Message)); } } public static void DevideByZero(int i) { int j = 0; int k = i/j; Console.WriteLine(k); } } } Now once you run this example. You will get following output as expected. Hope you like it. Stay tuned for more..

    Read the article

  • Actionscript 3.0 - drag and throw with easing

    - by Joe Hamilton
    I'm creating a map in flash and I would like to have a smooth movement similar to this: http://www.conceptm.nl/ I have made a start but I'm having trouble taking it to the next stage. My code currently throws the movieclip after the mouse is release but there is no easing while the mouse button is down. Any tips on how I would achieve this? Here is my current code: // Vars var previousPostionX:Number; var previousPostionY:Number; var throwSpeedX:Number; var throwSpeedY:Number; var isItDown:Boolean; // Event Listeners addEventListener(MouseEvent.MOUSE_DOWN, clicked); addEventListener(MouseEvent.MOUSE_UP, released); // Event Handlers function clicked(theEvent:Event) { isItDown =true; addEventListener(Event.ENTER_FRAME, updateView); } function released(theEvent:Event) { isItDown =false; } function updateView(theEvent:Event) { if (isItDown==true){ throwSpeedX = mouseX - previousPostionX; throwSpeedY = mouseY - previousPostionY; mcTestMovieClip.x = mouseX; mcTestMovieClip.y = mouseY; } else{ mcTestMovieClip.x += throwSpeedX; mcTestMovieClip.y += throwSpeedY; throwSpeedX *=0.9; throwSpeedY *=0.9; } previousPostionX= mcTestMovieClip.x; previousPostionY= mcTestMovieClip.y; }

    Read the article

  • Try-Catch-Throw in the same Java class

    - by Carlos
    Is it possible to catch a method in the current class the try-catch block is running on? for example: public static void arrayOutOfBoundsException(){ System.out.println("Array out of bounds"); } ..... public static void doingSomething(){ try { if(something[i] >= something_else); } catch (arrayOutOfBoundsException e) { System.out.println("Method Halted!, continuing doing the next thing"); } } If this is possible how will it be the correct way to call the catch method? If this is not possible, could anyone point me in the right direction, of how to stop an exception from halting my program execution in Java without having to create any new classes in the package, or fixing the code that produces ArrayOutOfBoundsException error. Thanks in Advance, A Java Rookie

    Read the article

  • Dont Throw Duplicate Exceptions

    In your code, youll sometimes have write code that validates input using a variety of checks.  Assuming you havent embraced AOP and done everything with attributes, its likely that your defensive coding is going to look something like this: public void Foo(SomeClass someArgument) { if(someArgument == null) { throw new InvalidArgumentException("someArgument"); } if(!someArgument.IsValid()) { throw new InvalidArgumentException("someArgument"); }   // Do Real Work } Do you see a problem here?  Heres the deal Exceptions should be meaningful.  They have value at a number of levels: In the code, throwing an exception lets the develop know that there is an unsupported condition here In calling code, different types of exceptions may be handled differently At runtime, logging of exceptions provides a valuable diagnostic tool Its this last reason I want to focus on.  If you find yourself literally throwing the exact exception in more than one location within a given method, stop.  The stack trace for such an exception is likely going to be identical regardless of which path of execution led to the exception being thrown.  When that happens, you or whomever is debugging the problem will have to guess which exception was thrown.  Guessing is a great way to introduce additional problems and/or greatly increase the amount of time require to properly diagnose and correct any bugs related to this behavior. Dont Guess Be Specific When throwing an exception from multiple code paths within the code, be specific.  Virtually ever exception allows a custom message use it and ensure each case is unique.  If the exception might be handled differently by the caller, than consider implementing a new custom exception type.  Also, dont automatically think that you can improve the code by collapsing the if-then logic into a single call with short-circuiting (e.g. if(x == null || !x.IsValid()) ) that will guarantee that you cant easily throw different information into the message as easily as constructing the exception separately in each case. The code above might be refactored like so:   public void Foo(SomeClass someArgument) { if(someArgument == null) { throw new ArgumentNullException("someArgument"); } if(!someArgument.IsValid()) { throw new InvalidArgumentException("someArgument"); }   // Do Real Work } In this case its taking advantage of the fact that there is already an ArgumentNullException in the framework, but if you didnt have an IsValid() method and were doing validation on your own, it might look like this: public void Foo(SomeClass someArgument) { if(someArgument.Quantity < 0) { throw new InvalidArgumentException("someArgument", "Quantity cannot be less than 0. Quantity: " + someArgument.Quantity); } if(someArgument.Quantity > 100) { throw new InvalidArgumentException("someArgument", "SomeArgument.Quantity cannot exceed 100. Quantity: " + someArgument.Quantity); }   // Do Real Work }   Note that in this last example, Im throwing the same exception type in each case, but with different Message values.  Im also making sure to include the value that resulted in the exception, as this can be extremely useful for debugging.  (How many times have you wished NullReferenceException would tell you the name of the variable it was trying to reference?) Dont add work to those who will follow after you to maintain your application (especially since its likely to be you).  Be specific with your exception messages follow DRY when throwing exceptions within a given method by throwing unique exceptions for each interesting case of invalid state. Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • clear explanation sought: throw() and stack unwinding

    - by Jerry Gagelman
    I'm not a programmer but have learned a lot watching others. I am writing wrapper classes to simplify things with a really technical API that I'm working with. Its routines return error codes, and I have a function that converts those to strings: static const char* LibErrString(int errno); For uniformity I decided to have member of my classes throw an exception when an error is encountered. I created a class: struct MyExcept : public std::exception { const char* errstr_; const char* what() const throw() {return errstr_;} MyExcept(const char* errstr) : errstr_(errstr) {} }; Then, in one of my classes: class Foo { public: void bar() { int err = SomeAPIRoutine(...); if (err != SUCCESS) throw MyExcept(LibErrString(err)); // otherwise... } }; The whole thing works perfectly: if SomeAPIRoutine returns an error, a try-catch block around the call to Foo::bar catches a standard exception with the correct error string in what(). Then I wanted the member to give more information: void Foo::bar() { char adieu[128]; int err = SomeAPIRoutine(...); if (err != SUCCESS) { std::strcpy(adieu,"In Foo::bar... "); std::strcat(adieu,LibErrString(err)); throw MyExcept((const char*)adieu); } // otherwise... } However, when SomeAPIRoutine returns an error, the what() string returned by the exception contains only garbage. It occurred to me that the problem could be due to adieu going out of scope once the throw is called. I changed the code by moving adieu out of the member definition and making it an attribute of the class Foo. After this, the whole thing worked perfectly: a try-call block around a call to Foo::bar that catches an exception has the correct (expanded) string in what(). Finally, my question: what exactly is popped off the stack (in sequence) when the exception is thrown in the if-block when the stack "unwinds?" As I mentioned above, I'm a mathematician, not a programmer. I could use a really lucid explanation of what goes onto the stack (in sequence) when this C++ gets converted into running machine code.

    Read the article

  • Can/Should you throw exceptions in a c# switch statement?

    - by Kettenbach
    Hi All, I have an insert query that returns an int. Based on that int I may wish to throw an exception. Is this appropriate to do within a switch statement? switch (result) { case D_USER_NOT_FOUND: throw new ClientException(string.Format("D User Name: {0} , was not found.", dTbx.Text)); case C_USER_NOT_FOUND: throw new ClientException(string.Format("C User Name: {0} , was not found.", cTbx.Text)); case D_USER_ALREADY_MAPPED: throw new ClientException(string.Format("D User Name: {0} , is already mapped.", dTbx.Text)); case C_USER_ALREADY_MAPPED: throw new ClientException(string.Format("C User Name: {0} , is already mapped.", cTbx.Text)); default: break; } I normally add break statements to switches but they will not be hit. Is this a bad design? Please share any opinions/suggestions with me. Thanks, ~ck in San Diego

    Read the article

  • 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

  • SQL SERVER – Convert Old Syntax of RAISEERROR to THROW

    - by Pinal Dave
    I have been quite a few comments on my Facebook page and here is one of the questions which instantly caught my attention. “We have a legacy application and it has been a long time since we are using SQL Server. Recently we have upgraded to the latest version of SQL Server and we are updating our code as well. Here is the question for you, there are plenty of places we have been using old style RAISEERROR code and now we want to convert it to use THROW. Would you please suggest a sample example for the same.” Very interesting question. THROW was introduced in SQL Server 2012 to handle the error gracefully and return the error message. Let us see quickly two examples of SQL Server 2012 and earlier version. Earlier Version of SQL Server BEGIN TRY SELECT 1/0 END TRY BEGIN CATCH DECLARE @ErrorMessage NVARCHAR(2000), @ErrorSeverity INT SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY() RAISERROR (@ErrorMessage, @ErrorSeverity, 1) END CATCH SQL Server 2012 and Latest Version BEGIN TRY SELECT 1/0 END TRY BEGIN CATCH THROW END CATCH That’s it! We are done! Reference: Pinal Dave (http://blog.SQLAuthority.com)Filed under: PostADay, SQL, SQL Authority, SQL Error Messages, SQL Query, SQL Server, SQL Tips and Tricks, T SQL

    Read the article

  • Build one to throw away vs Second-system effect

    - by m3th0dman
    One one hand there is an advice that says "Build one to throw away". Only after finishing a software system and seeing the end product we realize what went wrong in the design phase and understand how we should have really done it. On the other hand there is the "second-system effect" which says that the second system of the same kind that is designed is usually worse than the first one; there are many features that did not fit in the first project and were pushed into the second version usually leading to overly complex and overly engineered. Isn't here some contradiction between these principles? What is the correct view over the problems and where is the border between these two? I believe that these "good practices" are were firstly promoted in the seminal book The Mythical Man-Month by Fred Brooks. I know that some of these issues are solved by Agile methodologies, but deep down, the problem is still the principles still stand; for example we would not make important design changes 3 sprints before going live.

    Read the article

  • Throw Things at Me…In Person!

    - by Most Valuable Yak (Rob Volk)
    I have a few speaking engagements coming up in July.  I will be getting my Revenge on twice this week, first at the Steel City SQL User Group in Birmingham, Alabama July 17, 2012: New Horizon Computer Learning Center 601 Beacon Pkwy. West, Suite 106 Birmingham, AL 35209 Register: http://steelcitysqljul2012.eventbrite.com/ 6-8 pm CST Not content with that, with my hands behind my back, I will pull the same thing from my hat at SQL Saturday 122 in Louisville, KY on July 21, 2012: Schedule Register These include Revenge: The SQL Parts 1 AND 2!  New and improved with the new Office 2013 Preview!  (Ummm, not really). I will then Tame Unruly Data at SQL Saturday 126 in Indianapolis, IN in July 28, 2012: Schedule Register If you will be in any of those places at those times, and I owe you money, that would be the best time for you to collect.  Just make sure not to warn me first, otherwise I may not show.

    Read the article

  • Best way to throw exception and avoid code duplication

    - by JF Dion
    I am currently writing code and want to make sure all the params that get passed to a function/method are valid. Since I am writing in PHP I don't have access to all the facilities of other languages like C, C++ or Java to check for parameters values and types public function inscriptionExists($sectionId, $userId) // PHP vs. public boolean inscriptionExists(int sectionId, int userId) // Java So I have to rely on exceptions if I want to make sure that my params are both integers. Since I have a lot of places where I need to check for param validity, what would be the best way to create a validation/exception machine and avoid code duplication? I was thinking on a static factory (since I don't want to pass it to all of my classes) with a signature like: public static function factory ($value, $valueType, $exceptionType = 'InvalidArgumentException'); Which would then call the right sub process to validate based on the type. Am I on the right way, or am I going completely off the road and overthinking my problem?

    Read the article

  • Parabolic throw with set Height and range (libgdx)

    - by Tauboga
    Currently i'm working on a minigame for android where you have a rotating ball in the center of the display which jumps when touched in the direction of his current angle. I'm simply using a gravity vector and a velocity vector in this way: positionBall = positionBall.add(velocity); velocity = velocity.add(gravity); and velocity.x = (float) Math.cos(angle) * 12; /* 12 to amplify the velocity */ velocity.y = (float) Math.sin(angle) * 15; /* 15 to amplify the velocity */ That works fine. Here comes the problem: I want to make the jump look the same on all possible resolutions. The velocity needs to be scaled in a way that when the ball is thrown straight upwards it will touch the upper display border. When thrown directly left or right the range shall be exactly long enough to touch the left/right display border. Which formula(s) do I need to use and how to implement them correctly? Thanks in advance!

    Read the article

  • All chromium extensions throw errors since update to 13.10

    - by hugo der hungrige
    Since updating to 13.10 all chromium extensions generate errors: chrome.extension is not available: 'extension' is not allowed for specified context type content script, extension page, web page, etc.). [VM] binding (56):427 Uncaught TypeError: Cannot call method 'sendRequest' of undefined include.preload.js:105 Uncaught TypeError: Cannot read property 'onRequest' of undefined include.postload.js:473 GET http://edge.quantserve.com/quant.js superuser.com/:2047 GET http://www.google-analytics.com/__utm.gif?utmwv=5.4.5&utms=2&utmn=590704726…n%3D(organic)%7Cutmcmd%3Dorganic%7Cutmctr%3D(not%2520provided)%3B&utmu=qQ~ ga.js:61 chrome.extension is not available: 'extension' is not allowed for specified context type content script, extension page, web page, etc.). [VM] binding (56):427 Uncaught TypeError: Cannot read property 'onRequest' of undefined content.js:233 chrome.extension is not available: 'extension' is not allowed for specified context type content script, extension page, web page, etc.). [VM] binding (56):427 Uncaught TypeError: Cannot read property 'onRequest' of undefined injected.js:169 chrome.extension is not available: 'extension' is not allowed for specified context type content script, extension page, web page, etc.). [VM] binding (56):427 Uncaught TypeError: Cannot call method 'getURL' of undefined content_js_min.js:5 GET http://engine.adzerk.net/z/8476/adzerk2_2_17_47 superuser.com/:1719 Uncaught TypeError: Cannot call method 'sendRequest' of undefined How to fix this?

    Read the article

  • Chargeback and showback...both a 'throw back'

    - by llaszews
    Been getting asked again by customers and partners about chargeback and showback in the cloud so thought I would blog on my response to this question. Charge Back background, information and industry analysis: Cloud computing is all about shared resources. These shared resources are computer servers (including memory and CPU), network devices, hard disk storage, database servers, application servers, cooling, floor space, electricity and more. These resources are shared by departments within a company, or by a number of companies, when resources are hosted in the public or hybrid cloud. Currently, hosting providers that run other companies on their cloud platforms do not have an accurate way to measure the shared computing resources used by a specific user let alone used by a specific customer. Additionally, companies running their own cloud data centers, for private or hybrid clouds, have no way of measure and charging back the departments in the company that are using these shared cloud resources. In both cases, the lack of determine shared resource costs and to charge them back to the company, department or user that is using this resources is limited a clear measure of business benefit and impacting company’s ability to measure the Return on Investment (ROI). An IT chargeback system is an accounting strategy that applies the costs of IT services, hardware or software to the business unit in which they are used. This system contrasts with traditional IT accounting models in which a centralized department bears all of the IT costs in an organization and those costs are treated simply as corporate overhead. Showback involves showing the IT costs to a department or customer but not actually charging them for their IT usage. Showback is a gradual method of introducing chargeback into an enterprise. Most companies implement a show back mechanism before a full chargeback system is put in place. Oracle chargeback product: Oracle Enterprise Manager provides tools for defining detailed Chargeback plans spanning different metrics collected for each type of resources as well as defining Cost Centers for grouping costs across multiple developers. Chargeback plans can use not only usage based costs, but also configuration based costs (e.g. version of the platform) or fixed costs (e.g. flat-rate management fee). Chargeback has rich out of the box reports. Trending reports show how charge and resource consumption varies over time, while Summary reports show the breakdown of charges or usage by different dimensions such as Cost Center or Target Type. These reports help consumers in understanding how their charges relate to their consumption and also assist the IT department with budgeting and planning activities. With BI Publisher, the reports can be made available in a variety of formats such as PDF, HTML, Word, Excel or PowerPoint.

    Read the article

  • SEHException throw using Microsoft XACT Audio Framework (XACT3)

    - by Sweta Dwivedi
    I have been developing a game using Kinect + XNA and using Microsoft Audio Creation tool (XACT3) for managing my sound files and music, however in the code an SEHException is thrown whenever it tries to get the wave file from the wave Bank . . Sometimes the code works magically and all of a sudden it will start throwing this exception randomly ..I need a help on solving this exception /*Declaring Audio Engine for music*/ AudioEngine engine; SoundBank soundBank; WaveBank waveBank; Cue cue; /*Declaring Audio engine for sound effects*/ AudioEngine engine1; SoundBank soundbank; WaveBank wavebank; Cue effect; engine = new AudioEngine(@"Content\therapy.xgs"); soundBank = new SoundBank(engine, @"Content\Sound Bank.xsb"); **waveBank = new WaveBank(engine, @"Content\Wave Bank.xwb");** cue = null; engine1 = new AudioEngine(@"Content\Music_Manager\Sound_effects.xgs"); soundbank = new SoundBank(engine1, @"Content\Music_Manager\Sound1.xsb"); **wavebank = new WaveBank(engine1, @"Content\Music_Manager\Wave1.xwb");** effect = null; cue = soundBank.GetCue("hypnotizing"); cue.Play();

    Read the article

  • Save programmatically created Mesh to .X Files using SlimDX throw null exception

    - by zionpi
    Mesh has been created properly using SlimDX,but when I use the following line: Mesh.ToXFile(barMesh, "foo.x", XFileFormat.Text,CharSet.Unicode); It throws NullReferenceException,through monitor window I can see barMesh is not null, inside the mesh structrue, SkinInfo is null. If SkinInfo is the problem,then how can I initialize it properly?Internet doesn't seems have much information on this.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >