Three options for Exceptions ... opinions?

I've got a method login() which has many reasons why it might fail. As I see it I've got three options, and I'm interested in opinions on them, or any additional options ...
1) public void login(String userName, String password) throws ApplicationException, LoginException, InvalidPasswordException, InvalidUsernameException, UserDeceasedException, UserNotFoundException, AdminUserLoginException {}
Where LoginException extends ApplicationException, and all the other exceptions extend LoginException
This means that clients using the method can catch the exact exception they're interested in:
try
user.login(uname, pword);
catch (InvalidPasswordException e)
// process for invalid password
catch (InvalidUsernameException e)
// process for invalid username
catch ... etc
2) public void login(String pUserName, String pPassword) throws HouseApplicationException, LoginException {}
Where LoginException extends ApplicationException
This means that clients using the method wanting to know what went wrong need to do instanceof:
try
user.login(uname, pword);
catch (LoginException e)
if (e instanceof InvalidPasswordException)
// process for invalid password
else if (e instanceof InvalidUsernameException)
// process for invalid username
else if ...
3) public void login(String pUserName, String pPassword) throws HouseApplicationException, LoginException {}
Where LoginException extends ApplicationException
And LoginException has an overloaded constructor that takes a Login Exception Type (set as constants in the Login class):
public LoginException(String message, int loginExceptionType)
And a getter on this exception type attribute.
So when throwing the exception, the method would call:
throw new LoginException("Users password is incorrect", Login.INVALID_PASSWORD);
This means that the clients using the method need to check this as follows:
try
user.login(uname, pword);
catch (LoginException e)
if (e.getLoginExceptionType() == Login.INVALID_PASSWORD)
// process for invalid password
else if (e.getLoginExceptionType() == Login.INVALID_USERNAME)
// process for invalid username
else if ...
I hate option 1 because the method declaration looks horrible, and if you add another exception, and you continue with the "paradigm", you'd have to declare the new exception as also being thrown, and alter all the clients to deal with it.
I'm don't have any opinion as to whether option 2 is better than option 3 or vice versa.
I'm interested what others think ...
Thankyou!
k

I've got a method login() which has many reasons why
it might fail. Wrong design. Wrong security handling.
Exceptions are for handling abnormal conditions. You are using them to handle normal conditions.
An abnormal condition would be 'the database is gone'. A normal condition is wrong user/password. Your method should be returning a variable that indicates the state of the login.
You also have a security problem in that you are specifically handling user and password seperately. They should be handled as a unit. You should never tell anyone that the 'user' is wrong or the 'password' is wrong. Doing so makes it easier to break the security. You just tell them that the login failed.

Similar Messages

  • I suggest three options for upgrading to FCPX

    I suggest three options for upgrading to FCPX, the first is to increase the amount of keywords and the second is a mark appears in clips synchronized and the third is to be able to tell the program which clip it should use to name the clips synchronized, for example, have three files, cam 01 and cam 02 audio today when selecting these three files to FCPX names the new file name using synchronized audio but need to edit that new name is created using the name of one of the two cameras. grateful

    1.  Your question has nothing to do with the Apple Software Update for Windows application...which is the focus of this forum.
    2.  These are  user to user forums.  You are not addressing Apple in anyway.
    3.  Submit your feedback to Apple at http://www.apple.com/feedback.

  • My iTunes will ONLY backup my iPhone ONCE *SO* VERY quickly, almost as if it's done nothing... (not the three options for rollback as promised) HELP! Please Read...

    Hi there,
       thanks in advance for any help you can give me on this, but, my iTunes will perform a backup on my iPhone ONCE. By which I mean, it will do another new backup again if I want it to, and that's all fine... but it's supposed to hold (I think) THREE states of backup that the user has saved at various points in order that the user can choose and rollback/restore from whichever one they want.
    There is none of that. I get the drop-down menu if I choose to restore... but it's pointless as there's only ever one option.
    At the moment, no matter how close together I perform the backups, or how far apart... I get ONE backup saved in my iTunes.
    As far as I can tell this is also ONE backup between iCloud or the computer. i.e. I don't get one for each. Just whichever I performed most recently.
      iTunes absolutely DID NOT used to do this. I used to get the three options and it took a little bit of a wait for the backup process to go through fully.
      Can anybody help or shed some light on this?
    As a sidenote: It's slightly concerning that the backup process it performs is now lightning quick and it almost seems as if it's doing nothing, when in fact my iPhone is absolutely, irresponsibly rammed with everything... hence the worrying need for backups and solving this issue etc. etc.
      Please can anyone help me with this, or even give a little support?
    P.S. Yes, I fully anticipate being told not to have my iPhone so stuffed etc. etc. It's got about 1-2gb free and I figure you should get to use what you pay for
      Thank you so much in advance.

       I have to say, this is so weird because it's actually become this way in the past week maybe, and I'm sure me saying this here will be disputed, ridiculed and belittled, and that's absolutely fair, but I've got to say it... up until a few days ago, my iTunes sync/backup area really would keep more than one backup for my one, single iPhone. They were all timed and dated with a drop-down menu (which appeared if I clicked the restore button) to choose which one I wanted to roll back to, for example. Sure, I'd read about the three backups thing etc. etc. and perhaps I got that wrong or misunderstood, but I can honestly say, I only ever had at the most two backups, that I could drop-down and choose to restore from. They were there. Same iPhone. Different dates.
       At the time, when this seemed to be the case, the backing-up process took quite a while. I would leave it to progress while I went and made a cup of tea, come back and it still wasn't finished running. So, not really AGES, but a little while.
       Now, when I perform a backup, the progress bar almost shoots across to a finish. I'll 'fess up... that worries me most of all. I can live without the luxury of a menu of backups... but if it does it once, I'd like to be sure it does it at all.
    Much more importantly though, thank you for your replies so far.
    Any further input, even if it's to belittle or shame is totally welcome. I'd like to understand this a bit more.
    Thanks again.

  • P300 has three options for 256 GB SSD, two of which seem identical

    I'm strongly considering a ThinkStation P300 Tower. I would like my primary/boot drive to be an SSD, and as discussed here, that means I should select the SSD as the "First Hard Drive Bay" in the online configurator. For the P300, there are three different entries for 256 GB SSDs (I'll label them (i), (ii), and (iii)): (i) 2.5" 256GB SATA SolidState Drive [add $200.00]
    (ii) 2.5" 256GB SATA Solid State Drive (OPAL) [add $200.00]
    (iii) 256GB SATA 2.5" Solid State Drive (OPAL) [add $200.00] As you can see, all three are the same price (i.e., $200 USD above the base price). What is the difference between (i), (ii), and (iii)? OK, so obviously (ii) and (iii) have OPAL, whereas (i) doesn't. I'm not a computer expert, and I hardly know what OPAL is; a web search tells me that it is a standard by which data on a hard drive can be encrypted such that if the drive is stolen, the data has some additional layer of protection. My thinking is that even if I purchase an OPAL drive, I would need to somehow enable that functionality if I wanted it. So, maybe (ii) and (iii) are OPAL capable but not OPAL ready "out of the box"? Anyway, OPAL aside, what is the difference between (ii) and (iii)? Well, as far as I can tell, they are the same. I suppose one possibility is that they ARE the same and the duplicate entry is just a typo. Another possibility is that they are drives with the same, or essentially the same, specs but made by different manufacturers (Samsung? Seagate? Intel? etc.). Inbound Sales didn't know. I don't necessarily expect you to know, but do you have any idea what is the difference between the three 256 GB SSDs, and especially between (ii) and (iii)? Thanks for your time; you have been SO generous with it!

    Good question, and good catch on the configurator.  
    I don't know for sure why the configurator is listing two different drives for (ii) and (iii)...on the surface they appear to be the same.  I have a couple of theories as to why it's showing like that, but I need to go back and confirm before I put those out there as it could just cause a lot of confusion.  Based on what I know of the drives qualified and those actually available, I'd say in the 256GB OPAL class, there are maybe 4 different drives that your system could be built with...likely fewer as I suspect some of those have gone EOL.
    My guess, based on the pricing, is that in reality those selections are essentially the same.  Probably just an oversight that both are listed.
    I'm also looking into why that drive listing is so haphazard overall....it's really difficult to navigate.

  • How do I create a dropdown with three options so that only one is visible in a form (non-flowable)

    I'm working on a form which needs to provides three options for the user out of a drop down list. When the user chooses one option, only that subform is to be visible. Two of the three subforms are text fields, and the third subform is a series of fields which are editable by the user.
    How do i create a dropdown with three options in it, so that in each instance only one subform is visible? This needs to happen in the same space on the main form.

    Hi Nellie,
    Here is the form back to you. There were three main issues:
    In order for dynamic behaviour, like showing and hiding, the form must be saved as a Dynamic XML Form in the save-as dialog.
    While you can use a minus sign when naming objects and subforms, it will cause scripts to fail. I have changed the name of the subforms so that they now use an underscore.
    The dropdown had specified values in the Object > Binding palette (1, 2, 3), so the script needs to use these in the if statements.
    When sharing forms on Acrobat.com, the best option is to select the file in your workspace and then click Publish. This will make it available to anyone who has the published URL.
    I hope that helps,
    Niall

  • Do you have an option for block all incoming message and request EXCEPTED messages from my contacts?

    Please help!!To whom it may concernDear Madam/Sir who works for Skype & Microsoft  Dear all who can really help,  Do you have an option for block all incoming message and request EXCEPTED messages from my contacts? or Do you have any solution to solve my problem from begin to now in present time?  Even though, I set the Privacy settings: - Allow calls from... "people in my Contact list only"- Automatically received video and share screens with "people in my Contact list only"- Allow IMs from "people in my Contact list only"  I still received unknow users sent me messages in every day, contact requests etc. And they're all clearly spammings and identity thefts.  I only wanna contact with my family and my freinds here with Skype via my Windows device and my mobile phone (w/Android OS).  And this is the only way to contact with them, because they could use Skype only in overseas.  BUT I don't need new friend from other unknow Skype member.   I keep blocked all unknow spammers in every day.  However in this morning, I feel so scared with Skype on my mobile, I looked at my mobile Skype, I saw it automatically showed me the list of all blocked members. BUT they were all unblocked (contact unblocked) by my mobile (Android version) Skype itself automatically, and listed them one by one on the screen, and about 30 seconds later, they all were disappeared suddenly.  I don't know what do to now, is it indicating my account was hacked?And how could I found out all those members again and block them again and delete all of them for ever?  I appreciate if you would improve the privacy protection. Thank you very very very much. 

    Hrm... that may be true and this may be a function of the phone email client that Apple just doesn't do.
    No, I can easily MANUALLY delete the messages. I would prefer if I didn't have to do it twice, tho. Once on the mail server and once on the phone.
    What I think the phone needs to do is, when it checks the POP, anything NOT there should be removed locally. I think you are correct on POP; the phone will poll the mx (mail exchanger) and the mx will pass off the messages to the phone. The phone then keeps ALL of that unitl you manually delete it.
    If, say, I remove a message from the mx, I would like the phone, when next polls, to see that that particular message isn't on the server anymore and remove it locally.
    Perhaps it's just me but if I delete the message on the mx itself, via my ISP's webmail interface, I really don't want to have to remove it again from my phone.
    thxs!
    cheers
    rOot

  • Cannot place files from Bridge CC into Indesign CC 2014. No option for anything except Photoshop.

    I can no longer place files from Bridge CC into Indesign CC 2014. No option for anything except Photoshop.

    I can no longer place files from Bridge CC into Indesign CC 2014. No option for anything except Photoshop.

  • I recently bought a new macbook and installed Acrobate Pro. My settings/preferences did not come over and I do not have the same style options for my signature.  It now only allows me three options and the style I have been using for the last year is not

    I recently bought a new macbook and installed Acrobate Pro. My settings/preferences did not come over and I do not have the same style options for my signature.  It now only allows me three options and the style I have been using for the last year is not there.  How do I add additional options and get my preferred signature style back?

    Hi Amanda ,
    Which version of Acrobat are you using?
    Which signature style are you talking about?
    You can go ahead and try uninstalling and reinstalling it and see if that works for you .
    Use the cleaner tool to uninstall it .Here is the link.
    Download Adobe Reader and Acrobat Cleaner Tool - Adobe Labs
    You can refer to the following link to re install it .
    https://helpx.adobe.com/acrobat/kb/acrobat-downloads.html
    Regards
    Sukrit Dhingra

  • New firefoxis great. i keep many windows open. in ur earlier ver. I used to close it, it would ask for save and shut down as one of the three option,but in this new version it close all my window, how do i save my window tab?

    new firefox is great. I usually have many windows open. in your earlier version, when ever I used to close it, it would ask for save and shut down as one of the three option,but in this new version it close all my window, how do i save my window tab?

    See [[Firefox does not ask to save tabs and windows on exit]].
    Does this work for you?

  • BODS : Datastore options for SAP R/3 - need clarity for use

    Hi All.
    Another request to understand the datastore optiono n BOXI 3.1 BODS existing installation.
    We are trying to pull a new table from SAP R/3 into BODS and we find that ABAP program is not getting generated as expected. And terminates. When we tested a simple workflow.
    While creating a new datastore for SAP R/3 Source :
    When we look at the datastore we find the following options for R3 Source ;
    ABAP Execution option :
    Execute preloaded
    Generate and execute
    Under data transfer method we find ;
    Shared directory
    Direct download
    FTP
    Custom transfer
    Then we have working directory on sap server
    local directory
    generated ABAP Directory
    Am testing a simple workflow of pulling data from SAP R/3 in a dev machine.
    But am not understanding.
    which option of ABAP Execution, and data transfer , path would work in co-ordination.
    Because when i say direct download and say generate and execute it throws error.
    Can anyone help me with combinations of the options to choose for a R/3 source. And the implications thereof.
    I had created a folder under local bods server D:\Bodi. And given the path for data transfer.
    But the files are not getting generated for whatsoever reasons.
    Any advise on this would be helpful.
    Also found a bit unusual, that there was no button to test the connection to be correct or not, a TEST connection button is not there. Which i felt, could be included.
    Note : on the existing production system, we have chosen execute preloaded; shared directory on sap server. and shared that folder path for the user and given full rights. But while we try to do the same on the dev machine a test before transporting on production, a simple workflow does not work.
    would like to know what settings on sap server, really affect the data store options on the BODS
    thanks
    indu
    Edited by: Indumathy Narayanan on Jul 19, 2011 4:14 PM

    Indeed, BODS <> SAP connectivity can be tricky.
    For a development environment, I suggest you select the option "Generate and execute" for your "ABAP Execution Option." What this means is that DS will create, on the fly, small-ish ABAP programs. These ABAP programs will be written, in plain text, to a local directory on the DS job server, in the folder specified in "Generated ABAP Directory".  You can see them in there after an attempted job execution, assuming the job involves the creation of an ABAP program.  The ABAP program name is specified in the properties of an ABAP data flow, under Options > ABAP Program Name.  If you can't, perhaps the DS job server process doesn't have full rights to that folder - ?  After being generated on-the-fly, they'll be transferred to SAP to execute.  The SAP user you use to connect to SAP must have sufficient rights to upload-and-execute these ABAP programs, and that's a fairly substantial set of rights. What's required is documented in the BODS supplement for SAP. Often, to get things running, your friendly local Basis admin will grant SAP_ALL to the DS user, to see what rights are being invoked.
    Once all that jazz is working, you need to get the data back. There are a number of ways to do this. The method of data transfer is specified in "Data transfer method," where, ignoring "Custom transfer," you have three choices:
    1) Direct Download: easiest and slowest.  This method tells SAP to attempt to stick data in the client-side folder specified in "Local directory." Try this first.
    2) Shared folder: This is recommended when you have SAP being hosted on a Windows box. Basically: you set "Working directory on SAP Server" and "Data Services path to the shared directory" to point to the same folder.  SAP uses the "Working directory on SAP Server" to find this folder, and DS uses the other setting. So, for instance, if you were going to use the Shared folder method, you could set "Working directory on SAP Server" to "E:\BODS_Transfer", and, assuming E:\BODS_Transfer was shared-out as "BODS_Transfer", you could set "Data Services path to the shared directory" to
    dev12.somecompany.com\BODS_Transfer .  Then, you'd need to setup all the relevant security, as both SAP and DS need rights to read and write files in this folder.
    3) FTP (this is the method I usually use): SAP writes the "transport files" you're after (i.e., the data) in the folder specified in "Working directory on SAP Server". Then, you need to establish ftp connectivity to that folder from the DS job server's perspective, which you do by entering the ftp host name and the path to that folder in "FTP host name" and "FTP relative path to the SAP working directory".  In my opinion, the "relative" business is a little confusing, and I just typically enter the full ftp path, beginning the path w/ a forward slash, like "/usr/sap/tmp/BOBJ" or something like that.  You also need to obtain a separate username and password for the ftp connectivity. Note that this name and password has NOTHING to do with the SAP username and password; you're just setting-up DS to act as an ftp client. I strongly encourage you to test ftp connectivity by using a regular ftp client from the DS job server and attempt to connect to your ftp host using the username and password you were given, and attempting to fetch some sample test file. If you can't do this, manually, then DS won't be able to do it, either.
    Best wishes,
    Jeff Prenevost

  • Can't see pricing options for Creative Cloud. :'(

    Two things, Adobe:
    1. When I try to click the "See All Plans" button on this page (Cloud-based software and services for creatives | Adobe Creative Cloud) I'm taken to a blank page (except for the unhelpful footer). The error console on my browser says there are a couple of errors, which are usually where this comes from.
    plans:237 -- ReferenceError: Can't find variable: s
    test_and_target.js:1:132 -- ReferenceError: Can't find variable: mboxDefine
    I would love to see the pricing options for this service that you've built into all of your applications, but apparently I can't.
    2. Apparently the forum is the only way to tell you guys about technical problems?

    Hi ChristofferLu,
    Please refer the knowledge base article: http://helpx.adobe.com/creative-cloud/help/cc-desktop-download-error.html.
    Regards,
    Romit Sinha

  • Is there a key on the MacBook Pro to toggle display options for a projector

    I have had some difficulty getting my InFocus projector to consistently work correctly with my MacBook Pro. Is there a key on the MacBook Pro that toggles the options for projector display? There was one on my last MacBook and my previous PowerBook.
    Thanks -
    Dudley Warner

    No, there is no longer a key to control external display modes (it's F7 on my 1st gen MBP, but the option was removed along with the embedded numeric keypad in the Early 2008 models). There's not a substitute keyboard shortcut (with the exception of installing a macro player like Keyboard Maestro). Your main option is System Preferences > Displays (as stated, ticking the box to show Displays in the menu bar provides a helpful shortcut).

  • Best options for life (gulp) after iWeb...

    Hey Gang,
    Been using iWeb since its inception. I've learned to love it.
    Well- with the begining of iCloud and the transition away from MobileMe I see the writing on the wall. I realize alot of people will continue to use iWeb but I want to be proactive as I have several business websites created on my iMac.
    About 2 years ago I had a strange backup issue and lost everything. I nearly switched off of iWeb at that time but I just loved it too much.
    I want to start making the switch sooner than later as I know that Apple will eventually not support iWeb. It's only a matter of time before there is some quirk with a new OS version and it probably just won't open or whatever it may be...
    So- yesterday I spent 12 hours and tried out each of these sites: Wix, Snappages, Webs, Intuit Websites, Weebly, Yola, Google Sites, Jimdo, Roxer, Neosites, Vistaprint, Moonfruit, and Squarespace.
    They all left ALOT to be desired except Squarespace. I think it has potential.
    As an alternative, I also downloaded Adobe Muse and did not like it at all. I used Rapidweaver in the past and didn't think much of it. I see their new version is packed with tons of extra costs- no thanks!
    I'm left with Sandvox which I am going to try today.
    Here's my question: What do you folks suggest? Moving away from actual software (Sandvox)? Transitioning to web-based (Squarespace) ? I really like the drag/drop functionality of iWeb but realize I might have to make some concessions!
    A concern is working on multiple sites that reside on my comouter and constantly having to backup. I might be creating 2-3 more sites for friends so that would mean I have close to 10. Do I really want to do that and essentially become a webmaster? No so sure.
    I welcome all suggestions!
    PS- I'm not a newbie but I also have not created and uploaded via an ftp/host. I do however have domains etc...
    I'd like to do what is easiest and makes the most sense in the long run..
    D

    A few months ago I had a look around at what was available in the way of software and you can download a PDF from this page under "Alternative Website Design Software"...
    http://www.iwebformusicians.com/iWeb/Why-iWeb.html
    The main alternatives to iWeb, such as Sandvox and RapidWeaver, were not an option for me since they suffer from the same restrictions and cost a lot more. The other available drag and drop style software is either flawed or like, Freeway, antiquated and badly designed.
    The online site builders do seem to offer a good alternative but they can be just as restrictive, cost a lot more and still produce huge ammounts of code. Some claim to be free but you need to look at the real cost - especially if you have more than one site. They do offer portable versions of the site suitable for iPhone etc and this has become a necessity - at least for a business site.
    I chose to move on to a code entry style software and this has proved to be fairly easy since the one I use is WYSIWYG and I can see the changes in real time in the preview window. Its also cheaper than RapidWeaver and Sandvox and doesn't require add ons to optimize and upload the files.
    HTML5 will allow us to build better, more efficient websites but its not quite there yet. If I hadn't made the move to code entry software I think I would have been tempted to stick with iWeb for the time being and use one of the online site builders to create a separate portable version for cell phones as a stop gap.
    There has got to be a better way to create websites using drag and drop and I believe something will come along that will make apps like iWeb, Sandvox and RapidWeaver redundant. After all, why did Apple quit on iWeb?
    iWeb does offer two alternatives for publishing...
    http://www.iwebformusicians.com/iWeb/Publish-Website.html
    ... and there's any amount of hosting out there...
    http://www.iwebformusicians.com/iWeb/Website-Hosting.html
    The  MobileMe only features can be replaced with alternatives if you need them...
    http://www.iwebformusicians.com/iWeb/Comments-Password-Protect.html
    "I may receive some form of compensation, financial or otherwise, from my recommendation or link."

  • How do I view and open all my files again that are on my external hard drive?? Error message saying 'The disk you inserted was not readable by this computer' Three options are Initialize, Ignore or Eject.

    I have recently purchased Toshiba 1TB hard drive and I set it up and I was able to transfer all my files onto it such as my music, photos, documents. I had correctly ejected and used it again and all these files were safely stored and accessible afterwards. However after I rebooted my computer as it had been going slow and I had too much clogging it up once I reconnected the external hard drive I have error message saying 'The disk you inserted was not readable by this computer' Three options are Initialize, Ignore or Eject. How do I access all my files? I set it up to work on both mac and windows. I have tried both another mac and windows computer and same issue occurs?? I am worried that all my personal files are gone but am confused as the drive has had absolutely no damage to it as it was in a very short time frame and its never left the same spot. Any help would be greatly appreciated. Thanks

    Thanks for your quick response. I had a look at your discussion... I tried it on a Windows machine and I thought that was compatible with ExFAT?
    Therefore I need to attempt to use my external hard drive with a machine that boasts OS X 10.6.5 or above and then it should work?
    Thanks

  • I often download tv shows on apple tv. All of a sudden I don't have the option to download tv shows but can download movies. Internet connection is good. I simply don't have the search or download options for tv. What is happening?

    I often download tv shows on apple tv. All of a sudden, my screen does not display download options for tv shows. I can download movies no problem
    and the Internet connection is good. It just no longer shows options for tv shows except for my tv shoes (already downloaded). what is going on?

    Welcome to the Apple Community.
    Check your store location is set correctly, if this doesn't help, try restarting the Apple TV by removing ALL the cables for a 30 seconds.

Maybe you are looking for