• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can I tell this code to move on when it finds this invalid value?

 
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have code that looks through a list of projects and for every channel it finds it populates the channel class with data using the channelID (because the channelID is needed to complete the url to access the web service holding the xml).

However somehow a channel ID got in that has no data associated with it, and whats more it contains a space so it creates an dinvalid uri since uris cannot have spaces.

So how can I tell this code to skip over this case, and start from the beginning of the for loop in an instance like this?

Here is the code:




channelUrl=projectChannel.getChannelId(); is returning a value of Channel 2, whch first off has no actual channel associated with that ID, plus it creates an invalid uri - www.project/channels/Channel 2

SO I need a way to handle this without it stopping everything, I need it to just skip over this and move on....any suggestions?
 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about using continue statement ? Will it serve the purpose ?

Hope this helps ,
 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
never used one so I will have to look into it, thanks though
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Move the last two statements into the "try"?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is every single line of code really commented?!
 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lmao, yes I commented every single line of code in my program, because this is being passed on to the company once I get it where I am supposed to lol. Im just trying to be helpful

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just an observation--it's not necessarily helpful to over-comment: it's another point of failure, and one that isn't capture-able by tests or compilers. Keeping comments "in-sync" with code is a *lot* of work--eliminate the need to do so whenever possible. For example:Here you basically wrote the code twice, just in a different order, and one time (the comment) is completely unverifiable except by reading it and its accompanying code. That's not helpful, that's just noise, and if it *does* get out-of-sync with the code, it's dangerously misleading noise. It'd be cleaner, and easier, to just write
 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the tip, I will keep that in mind, Im sure it will be helpful for me in the future
 
Ruth Stout was famous for gardening naked. Just like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic