Skip to content

File NPException.cxx

File List > core > NPException.cxx

Go to the documentation of this file

#include "NPException.h"
#include "NPTerminalColor.h"
#include <iostream>
void nptool::DisplayException(Exception& Ex) {
  std::string Env = getenv("NPTOOL_HOME");
  int res;
  if (Env.back() != '/')
    Env += "/";
  Env += getenv("NPTOOL_ENV");
  if (Ex.IsError()) {
    std::clog << cli_red;
    std::clog << cli_horizontal;
    std::clog << "ERROR: the folowing " << nptool::cli_blue << "nptool ";
    std::clog << nptool::cli_red << "exception is causing an error:\n";
    std::clog << Ex.what() << "\n";
    std::clog << "-> Following line from: " << Env << "/nptool.log may help \n";
    std::clog << cli_horizontal;
    std::clog << cli_restore_color;

    std::string command = "tail "+Env+"/nptool.log";
    res = system(command.c_str());
  }
  else if (Ex.IsWarning()) {
    std::clog << cli_yellow;
    std::clog << cli_horizontal;
    std::clog << "WARNING: the folowing " << nptool::cli_blue << "nptool ";
    std::clog << nptool::cli_yellow << "exception is causing a warning:\n";
    std::clog << Ex.what() << "\n";
    std::clog << "-> See log file : " << Env << "/nptool.log\n";
    std::clog << cli_horizontal;
    std::clog << cli_restore_color;
  }
}