Commit 74a661ae authored by sjplimp's avatar sjplimp Committed by GitHub
Browse files

Merge pull request #328 from akohlmey/print-last-command-on-error

print the last input line, when error->all() is called
parents d8bc590a 1a81da0f
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "error.h"
#include "universe.h"
#include "output.h"
#include "input.h"

using namespace LAMMPS_NS;

@@ -107,11 +108,18 @@ void Error::all(const char *file, int line, const char *str)
  MPI_Barrier(world);

  int me;
  const char *lastcmd = (const char*)"(unknown)";

  MPI_Comm_rank(world,&me);

  if (me == 0) {
    if (screen) fprintf(screen,"ERROR: %s (%s:%d)\n",str,file,line);
    if (logfile) fprintf(logfile,"ERROR: %s (%s:%d)\n",str,file,line);
    if (input && input->line) lastcmd = input->line;
    if (screen) fprintf(screen,"ERROR: %s (%s:%d)\n"
		        "Last command: %s\n",
                        str,file,line,lastcmd);
    if (logfile) fprintf(logfile,"ERROR: %s (%s:%d)\n"
		         "Last command: %s\n",
                         str,file,line,lastcmd);
  }

#ifdef LAMMPS_EXCEPTIONS
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ namespace LAMMPS_NS {

class Input : protected Pointers {
  friend class Info;
  friend class Error;
 public:
  int narg;                    // # of command args
  char **arg;                  // parsed args for command
+4 −4

File changed.

Contains only whitespace changes.