errset doesn't work for a certain construct

Discussion in 'Cadence' started by snmishra, Sep 26, 2003.

  1. snmishra

    snmishra Guest

    Hi All

    I used this piece of code to catch an error. But it doesn't work. I
    still get the error message and a failed program when I use it with
    spectre simulator. Any ideas why? I am hoping for a quick answer from
    somebody who has seen this before. I will also contact the CAD support
    people at our company tomorrow.

    (errset (asiGetEnvOptionVal (asiGetCurrentSession) 'modelPath) nil)

    Thanks
    Satya
     
    snmishra, Sep 26, 2003
    #1
  2. That's because it doesn't actually throw an error - it just prints a message
    that looks like an error.

    You can detect this with the return value from errset - in this case it will
    be (nil) - if there had truly been an error, the return value would be nil.
    So in this case there's no benefit in wrapping in an errset().

    However, I can't see why you'd get a "failed" program, since it
    shouldn't actually create a real error.

    So here's what you can do:

    1. Somewhere in your code, define the following global variable:

    (setq ABnullport (outfile "/dev/null"))

    2. Swallow these "fake" errors by surrounding with a let:

    (let ((errport ABnullport))
    (asiGetEnvOptionVal (asiGetCurrentSession) 'modelPath)
    )

    This works by dynamically scoping the errport variable (containing
    the port where error information is written to) to point to the
    null port. That way the error messages don't appear, and the
    return value of the let is the return value of the last thing in the
    let (in this case the asiGetEnvOptionVal() call).

    You can leave the ABnullport variable open for the whole session,
    so you could always make the code do something like this when opening
    it:

    (unless (and (boundp 'ABnullport) (openportp ABnullport))
    (setq ABnullport (outfile "/dev/null"))
    )

    if you're going to have that part of the code executed multiple times.

    Andrew.
     
    Andrew Beckett, Sep 26, 2003
    #2
  3. snmishra

    snmishra Guest

    Andrew

    Thanks for the answer. I realized that I didn't get the failure
    from the asiGetEnvOptionVal but from asiSetEnvOptionVal that I had in
    the next line. But it would be nice to be able to get rid of the fake
    error message too.

    Once again thanks for the solution.

    Satya

    Andrew> That's because it doesn't actually throw an error - it
    Andrew> just prints a message that looks like an error.

    Andrew> You can detect this with the return value from errset - in
    Andrew> this case it will be (nil) - if there had truly been an
    Andrew> error, the return value would be nil. So in this case
    Andrew> there's no benefit in wrapping in an errset().

    Andrew> However, I can't see why you'd get a "failed" program,
    Andrew> since it shouldn't actually create a real error.

    Andrew> So here's what you can do:

    Andrew> 1. Somewhere in your code, define the following global
    Andrew> variable:

    Andrew> (setq ABnullport (outfile "/dev/null"))

    Andrew> 2. Swallow these "fake" errors by surrounding with a let:

    Andrew> (let ((errport ABnullport)) (asiGetEnvOptionVal
    Andrew> (asiGetCurrentSession) 'modelPath) )

    Andrew> This works by dynamically scoping the errport variable
    Andrew> (containing the port where error information is written
    Andrew> to) to point to the null port. That way the error messages
    Andrew> don't appear, and the return value of the let is the
    Andrew> return value of the last thing in the let (in this case
    Andrew> the asiGetEnvOptionVal() call).

    Andrew> You can leave the ABnullport variable open for the whole
    Andrew> session, so you could always make the code do something
    Andrew> like this when opening it:

    Andrew> (unless (and (boundp 'ABnullport) (openportp
    Andrew> ABnullport)) (setq ABnullport (outfile "/dev/null")) )

    Andrew> if you're going to have that part of the code executed
    Andrew> multiple times.

    Andrew> Andrew.


    Andrew> On 25 Sep 2003 18:39:47 -0600,

    Andrew> -- Andrew Beckett Senior Technical Leader Custom IC
    Andrew> Solutions Cadence Design Systems Ltd
     
    snmishra, Sep 26, 2003
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.