Logo Search packages:      
Sourcecode: sam2p version File versions

GenBuffer::Writable & Error::sev ( level_t  level  )  [static]

This is the (carefully hidden :-)) method of raising errors (i.e displaying error messages and terminating the program). Example usage: Error::sev(Error::WARNING_DEFER) << "check_rule: /BMP requires " "/Predictor " << 1 << (Error*)0; The error is interpreted according to the current policy. The policy divides errors into three categories:

-- secret: nothing happens (even the error message is _not_ printed) -- recorded: nothing happens (even the error message is _not_ printed), but the message is remembered for further processing. -- printed: the error message is printed, and program execution continues Before printing this message, all recorded errors on the policy stack are also printed (deepest first). -- killer: like `printed', but runs cleanup handlers and terminates the program immediately.

Parameters:
level is one of the constants mentioned above (FATAL, EERROR, WARNING, NOTICE etc). Can be positive, zero or negative. The larger the `level', the more severe the error is. The default policy is: level>=0 errors are killer, -99<=level<=-1 errors are printed, -199<=level<=-100 are recorded and level<=-200 errors are secret.

Definition at line 55 of file error.cpp.

References Error::Policy::curlev, Error::Policy::err, level2str(), policy_top, Error::Policy::printed, Error::Policy::record, Error::Policy::recorded, Error::Policy::topRecorded, and Error::Policy::topSecret.

Referenced by Image::Sampled::addAlpha0(), Rule::applyProfile(), Rule::buildProfile(), Filter::UngetFILED::getFILE(), popPolicy(), Filter::UngetFILED::seek(), Filter::PipeE::vi_copy(), Filter::PipeE::vi_write(), JPEGSOF0Encode::vi_write(), Rule::writeTTE(), Rule::writeTTM(), Rule::writeTTT(), and MiniPS::Tokenizer::yylex().

                                           {
  /* So they are trying to make an error? Let's see whether they can. */
  GenBuffer::Writable *err=policy_top->err;
  // printf("curlev=%d\n", policy_top->curlev);
  assert(policy_top->curlev==-9999 && "nested error/ unfinished prev err");
  policy_top->curlev=level;
  /* printf("level=%d\n", level); */
  if (level>=policy_top->printed) { /* printed or killer */
    #if 0 /* Disables printing of "using template: " */
      /* vvv Delay printing this message after all recorded messages */
      if (policy_top->record!=NULLP) err=policy_top->record;
    #endif
  } else if (level>=policy_top->recorded) { /* recorded */
    if (NULLP==(err=policy_top->record)) err=policy_top->record=new SimBuffer::B();
    if (level>policy_top->topRecorded) policy_top->topRecorded=level;
  } else { /* secret */
    if (level>policy_top->topSecret) policy_top->topSecret=level;
    return devNull;
  }
  return *err << (argv0==(char const*)NULLP?"??argv0":argv0) << ": " << level2str(level) << ": ";
  /* Processing will continue soon by GenBuffer::Writable& operator <<(GenBuffer::Writable& gb,Error*) */
}


Generated by  Doxygen 1.6.0   Back to index