whatYouInvoked: FYI: Hi Mom! Love you much! --- If I really do want the file/line info, I add that into an exception, throw it, and catch it for display (or logging) elsewhere. Joseph Beckenbach lead XP tester, Eidogen Inc. [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <50464.216.135.205.211.1077296527.squirrel@castle> [ref] => <1077254217.275466.32565.nullmailer@picachu.netlab.jp><63252.203.185.214.34.1077241947.squirrel@webmail.imagineis.com><4035B01E.6040509@hypermetrics.com> [htmlstate] => on_nl2br [postusername] => jrb3@eidogen.com [ip] => jrb3@eidogen.co [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 19 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> > whatYouInvoked: FYI: Hi Mom! > Love you much! > ---[/ref] Joseph Beckenbach lead XP tester, Eidogen Inc. [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <50549.216.135.205.211.1077297420.squirrel@castle> [ref] => <1077254217.275466.32565.nullmailer@picachu.netlab.jp><63252.203.185.214.34.1077241947.squirrel@webmail.imagineis.com><4035B01E.6040509@hypermetrics.com><50464.216.135.205.211.1077296527.squirrel@castle> [htmlstate] => on_nl2br [postusername] => jrb3@eidogen.com [ip] => jrb3@eidogen.co [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 20 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> how to raise warning? - Ruby

how to raise warning? - Ruby

How to raise warning?...

  1. #1

    Default how to raise warning?

    How to raise warning?
    Szymon Guest

  2. #2

    Default Re: how to raise warning?


    "Szymon Drejewicz" <edu.pl> schrieb im Newsbeitrag
    news:c0vhrk$if$wsisiz.edu.pl... 

    Do you mean:

    How to raise an exception? ("raise Exception, msg")

    How to print out a warning? ("$stderr.puts "This is a warning")

    or what?

    robert



    Robert Guest

  3. #3

    Default Re: how to raise warning?

    On Wed, 18 Feb 2004 13:39:50 +0100, Robert Klemme wrote: 
    >
    > Do you mean:
    >
    > How to raise an exception? ("raise Exception, msg")
    >
    > How to print out a warning? ("$stderr.puts "This is a warning")
    >[/ref]

    There is also #warn

    server> irb
    irb(main):001:0> warn("hello")
    hello
    => nil
    irb(main):002:0>


    --
    Simon Strandgaard
    Simon Guest

  4. #4

    Default Re: how to raise warning?

    On Wednesday, February 18, 2004, 10:24:54 PM, Szymon wrote:
     

    warn "message"

    Gavin



    Gavin Guest

  5. #5

    Default Re: how to raise warning?

    I need something like 'weak exception' raising. "warn 'message' " works like
    "puts 'message'", but I'd like to have line number like I have when I raise
    exception.

    --
    Szymon Drejewicz
    Szymon Guest

  6. #6

    Default Re: how to raise warning?


    "Szymon Drejewicz" <edu.pl> schrieb im Newsbeitrag
    news:c100nt$p0s$wsisiz.edu.pl... 
    like 
    raise 

    warn "#{__FILE__}:#{__LINE__}: there is an error"

    robert

    Robert Guest

  7. #7

    Default Re: how to raise warning?

    On Wed, 18 Feb 2004 16:35:29 +0100, Szymon Drejewicz <edu.pl>
    wrote:
     

    The Kernel#caller method gives you the trace information. So you
    can redefine Kernel#warn along these lines:

    module Kernel
    alias :oldwarn :warn
    def warn(msg="", fulltrace=nil)
    trace = caller(1)
    where = trace[0].sub(/:in.*/,'')
    $stderr.puts "#{where}: Warning: #{msg}"
    $stderr.puts trace.map {|t| "\tfrom #{t}"} if fulltrace
    end
    end


    regards,
    andrew
    Andrew Guest

  8. #8

    Default Re: how to raise warning?

    > module Kernel 

    Yes, this is exactly what I need :-) thank you
    Now it is possible to use just

    warn "Message body"

    and ruby adds line number by itself without using redundant syntax like

    warn "#{__FILE__}:#{__LINE__}: Message body."

    :-)

    --
    Szymon Drejewicz
    Szymon Guest

  9. #9

    Default Re: how to raise warning?

    Hi!

    * Robert Klemme: 

    If it is an error it raises an exception. A warning is used when
    there is doubt wether something is wanted:

    warn "#{__FILE__}:#{__LINE__}: no config file, using defaults"

    As a rule of thumb a warning can be replaced by an 'Are you sure?'
    dialog.

    Josef 'Jupp' SCHUGT
    --
    http://oss.erdfunkstelle.de/ruby/ - German comp.lang.ruby FAQ
    http://rubyforge.org/users/jupp/ - Ruby projects at Rubyforge


    Josef Guest

  10. #10

    Default Re: how to raise warning?

    Hi,

    In message "Re: how to raise warning?"
    on 04/02/19, "Robert Klemme" <net> writes:

    |warn "#{__FILE__}:#{__LINE__}: there is an error"

    Do you guys expect "warn" to prepend the place information before the
    message?

    matz.


    Yukihiro Guest

  11. #11

    Default Re: how to raise warning?

    > Hi, 


    I don't. A warning is often a user-level piece of information that does
    not warrant file and line information.

    Having a variant of 'warn' that displays that information would be nice IMO.

    warn "You didn't provide such and such", true

    Not perfect, but not bad.

    Gavin




    Gavin Guest

  12. #12

    Default Re: how to raise warning?

    Gavin Sinclair wrote: 
    >
    >
    >
    > I don't. A warning is often a user-level piece of information that does
    > not warrant file and line information.
    >
    > Having a variant of 'warn' that displays that information would be nice IMO.
    >
    > warn "You didn't provide such and such", true[/ref]

    Mmm. I would expect that just to print 'true' after the warning.

    The problem as I see it is that we use warnings in two ways:
    1. As Ruby does, to complain about something happening at a specific
    place in the source -- a highly source-related message. In that
    case, I'd want to see file/line info (as Ruby does when it says I
    need to add parens or something).
    2. To complain about some general condition occurring at runtime that
    doesn't warrant bailing out of the app.

    My suggestion: Two names. Call the first one "warning" (the kind of
    warning that Ruby gives us) and the second one "warn" (a simple verb
    that just prints to stderr).

    Hal



    Hal Guest

  13. #13

    Default Re: how to raise warning?

    Hal Fulton wrote:
    ... 

    If we were talking about exceptions, the distinction between 1 and 2
    would be the distinction between ScriptError and StandardError. Maybe
    there should be Warning classes, ogous with Exception classes? This
    would give us the flexibility of saying which Warning classes we want to
    be reported ("ruby --ignore-warning=ScriptWarning").


    Joel Guest

  14. #14

    Default Re: how to raise warning?


    On Feb 19, 2004, at 11:50 PM, Gavri Savio Fernandez wrote:
     
    >>
    >> Mmm. I would expect that just to print 'true' after the warning.[/ref][/ref]
    I second that. Adding an optional boolean argument to the function to
    get different results doesn't quite seem rubyish to me.
     
    >
    > One of the main things I like about Ruby is that the names are so
    > intuitive.
    > Once i check out a particular class or method in the reference, it is
    > pretty much guaranteed that i won't forget it ever. Even better,
    > sometimes i just guess what the name of a particular entity might be,
    > type it in and the program runs. This, for me, is a major plus for
    > ruby.
    > Even if a particular name is esoteric, it is esoteric in a way i
    > remember and find difficult to forget.
    >
    > Okay, what i'm driving at is this: Naming one method 'warn' (A verb. I
    > like that) and another 'warning' (A noun. Don't like it much) is quite
    > confusing :(
    > There doesn't seem to be any clue in their names to differentiate
    > their functionality from each other.[/ref]

    How about:
    warn "Server timed out. retrying."
    warn! "That number seemed a bit high... Possible error."

    This would keep the old behavior for warn(), but add a new function
    warn!(), which would be used for more serious warnings where you want
    to include a traceback.

    -Mark



    Mark Guest

  15. #15

    Default Re: how to raise warning?


    "Hal Fulton" <com> schrieb im Newsbeitrag
    news:com... 
    > >
    > >
    > >
    > > I don't. A warning is often a user-level piece of information that[/ref][/ref]
    does [/ref]
    nice IMO. 
    >
    > Mmm. I would expect that just to print 'true' after the warning.
    >
    > The problem as I see it is that we use warnings in two ways:
    > 1. As Ruby does, to complain about something happening at a specific
    > place in the source -- a highly source-related message. In that
    > case, I'd want to see file/line info (as Ruby does when it says I
    > need to add parens or something).
    > 2. To complain about some general condition occurring at runtime that
    > doesn't warrant bailing out of the app.[/ref]

    Good ysis!
     

    I like the suggestion, but I'm not fully satisfied with the naming. They
    are too similar and thus too easy to confuse. Trying to think of
    something better... What about leaving "warn" as it is (i.e. no info on
    location) and one of "report" or "source_warn" for a message with file and
    line info? This way, no existing code would be broken and we had a clear
    naming distinction.

    Regards

    robert


    Robert Guest

  16. #16

    Default Re: how to raise warning?


    "Mark Hubbart" <com> schrieb im Newsbeitrag
    news:com... [/ref]
    > I second that. Adding an optional boolean argument to the function to
    > get different results doesn't quite seem rubyish to me.[/ref]

    It's generally considered bad to have an interface method that changes
    it's behavior dependend on a flag. The typical solution is to have two
    methods for the job. If they have something in common they can use a
    private method for the implementation.
     
    > >
    > > One of the main things I like about Ruby is that the names are so
    > > intuitive.
    > > Once i check out a particular class or method in the reference, it is
    > > pretty much guaranteed that i won't forget it ever. Even better,
    > > sometimes i just guess what the name of a particular entity might be,
    > > type it in and the program runs. This, for me, is a major plus for
    > > ruby.
    > > Even if a particular name is esoteric, it is esoteric in a way i
    > > remember and find difficult to forget.
    > >
    > > Okay, what i'm driving at is this: Naming one method 'warn' (A verb. I
    > > like that) and another 'warning' (A noun. Don't like it much) is quite
    > > confusing :(
    > > There doesn't seem to be any clue in their names to differentiate
    > > their functionality from each other.[/ref]
    >
    > How about:
    > warn "Server timed out. retrying."
    > warn! "That number seemed a bit high... Possible error."
    >
    > This would keep the old behavior for warn(), but add a new function
    > warn!(), which would be used for more serious warnings where you want
    > to include a traceback.[/ref]

    Ops, didn't read your post before I send mine. Similar thoughts. :-)

    Kind regards

    robert

    Robert Guest

  17. #17

    Default Re: how to raise warning?

    Hi,

    At Fri, 20 Feb 2004 20:53:21 +0900,
    Robert Klemme wrote in [ruby-talk:93233]: 
    >
    > I like the suggestion, but I'm not fully satisfied with the naming. They
    > are too similar and thus too easy to confuse. Trying to think of
    > something better... What about leaving "warn" as it is (i.e. no info on
    > location) and one of "report" or "source_warn" for a message with file and
    > line info? This way, no existing code would be broken and we had a clear
    > naming distinction.[/ref]

    Doesn't perl use carp or croak for it?

    --
    Nobu Nakada


    nobu.nokada@softhome.net Guest

  18. #18

    Default Re: how to raise warning?

    On Fri, 20 Feb 2004 15:58:48 +0900, Hal Fulton
    <com> wrote:
     
    My faithful online thesaurus suggests "alert" or "caution" as good,
    distinctive synonyms for "warn".
    Tim Guest

  19. #19

    Default Re: how to raise warning?

     
    >
    > Mmm. I would expect that just to print 'true' after the warning.
    >
    > The problem as I see it is that we use warnings in two ways:
    > 1. As Ruby does, to complain about something happening at a specific
    > place in the source -- a highly source-related message. In that
    > case, I'd want to see file/line info (as Ruby does when it says I
    > need to add parens or something).
    > 2. To complain about some general condition occurring at runtime that
    > doesn't warrant bailing out of the app.
    >
    > My suggestion: Two names. Call the first one "warning" (the kind of
    > warning that Ruby gives us) and the second one "warn" (a simple verb
    > that just prints to stderr).[/ref]

    Well, I use 'fyi' for the second (acronym common in the United States
    standing for "For Your Information"). Since the application name tends to
    be more interesting than the file and line information for the end-user, I
    have the application name in the output.

    ---
    def fyi( *message )
    puts( "#{}: FYI: " + message.join('\n\t') )
    end
    fyi "Hi Mom!" "Love you much!"

    -->
    whatYouInvoked: FYI: Hi Mom!
    Love you much!
    ---

    If I really do want the file/line info, I add that into an exception,
    throw it, and catch it for display (or logging) elsewhere.

    Joseph Beckenbach
    lead XP tester, Eidogen Inc.


    jrb3@eidogen.com Guest

  20. #20

    Default Re: how to raise warning?

    Whoops, missing an important part there, sorry ....

     
    #!/usr/bin/ruby
    ME = File.basename( $0 ) 
    puts( "#{ME}: FYI: " + message.join('\n\t') ) 

    Joseph Beckenbach
    lead XP tester, Eidogen Inc.


    jrb3@eidogen.com Guest

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: December 20th, 11:48 PM
  2. Not able to Raise Events
    By King Kong in forum ASP.NET Building Controls
    Replies: 0
    Last Post: January 3rd, 07:26 AM
  3. gnu-regexp should raise?
    By Simon in forum Ruby
    Replies: 2
    Last Post: November 27th, 02:45 PM
  4. FOX and raise
    By Lyle Johnson in forum Ruby
    Replies: 0
    Last Post: July 28th, 04:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •