Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

catching warnings

 
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Is it possible to catch "warnings" like we catch exceptions.

warning is being generated by a third party utility used in our project. I need to handle it.

Thanks,
Neeraj.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does the third party utility get executed?
How does the third party utility "tell" you this warning?

If it writes output to standard error stream or standard output stream - that appears in command prompt window, you could probably capture that output and parse it.

Bill
 
author and cow tipper
Posts: 5001
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know Eclipse and IRAD display alot of warning. Acutally, ALOT of warnings in my code. I can't catch them programatically.

Perhaps I should take a better look at my code though. Maybe the tool is telling me something.

I don't know your tool or development environment, but I highly doubth there's a mechanism for handling warnings at compile or runtime, although I do enjoy being proven wrong (it happens fairly often).

-Cameron McKenzie
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the warnings are produced using some logging tool (for example log4j), you might be able to register your own logger and somehow analyze the warnings.

But warnings aren't a standard mechanism in Java, so we need to know how those warnings are produced to give you more useful hints.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, however this third-party tool works, I'm pretty sure it won't be like catching an exception. Throwing an exception implies that the application is not going to continue processing whatever it's supposed to process; instead, execution will resume at the appropriate catch block (if there is one). However the term "warning" indicates that, although there may be a problem of some sort, the application will not stop processing, but will instead keep going. So throwing an exception would be an inappropriate response for anything which is described as a "warning".
[ January 01, 2007: Message edited by: Jim Yingst ]
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Thanks for your inputs. I am trying to implement JBoss cache in my project. Warning is thrown by class file from JBoss, when it is unable to find a particular node. Though I was catching the exception, when there is some problem in deleting the node by JBOSS. it is not reaching the catch block, it just throws a warning and continues. I need some help on it.

Thanks,
Neeraj.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

it just throws a warning and continues.



Seems to me that no "warning" object is "thrown" - a warning message is written.

Therefore the question is: WHERE is the message written and can you intercept and parse it? What do the JBoss cache docs have to say?

Bill
[ January 03, 2007: Message edited by: William Brogden ]
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Neeraj Vij:
Though I was catching the exception, when there is some problem in deleting the node by JBOSS. it is not reaching the catch block, it just throws a warning and continues.



AFAIK, JBossCache uses log4j to log messages. Why would you want to rely on those warning messages? Instead there's a API in JBossCache named



which tells you whether a node exists or not
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your inputs.

warning message is coming in the logs on the console. I am unable to find a way to capture that warning message.

Thanks,
Neeraj.
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems that the Original Poster is mis-using terms like "catch", which have a very specific meaning in Java.

However, for readers' interest, I thought I'd point out that other languages do have a programmatic mechanism for dealing with warnings. My boss was telling me about it, so it was probably in some flavours of Lisp. I believe that handling of warnings is optional and execution resumes from the same point after any handler has run. Sounds a Good Thing (TM). If anyone can tell me more, I'd be (somewhat) interested to know.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Peter Chase:
It seems that the Original Poster is mis-using terms like "catch", which have a very specific meaning in Java.



Exactly. Not only that, the word Warning is also being misunderstood in this context. The Warning that the poster is refering to is just a level in log4j to log messages. Also relying on those messages (which can be turned off anytime using log4j configurations) for doing some business logic does not seem right. Just my thoughts.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic