Skip to content

Commit

Permalink
Print an understandable message when a user-specified path/file does …
Browse files Browse the repository at this point in the history
…not exist

Closes idaholab#15718
  • Loading branch information
fdkong authored and jiangwen84 committed Sep 15, 2020
1 parent 106873e commit c2b0b58
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions framework/src/utils/MooseUtils.C
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,20 @@ realpath(const std::string & path)
{
#ifdef LIBMESH_HAVE_PETSC
char dummy[PETSC_MAX_PATH_LEN];
#if defined(PETSC_HAVE_REALPATH)
// If "realpath" is adopted by PETSc and
// "path" does not exist, then PETSc will print a misleading message.
// [0]PETSC ERROR: Error in external library
// [0]PETSC ERROR: realpath()
// [0]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
// [0]PETSC ERROR: Petsc Release Version 3.13.3, unknown
// We here override the misleading message with a better one.
if (!::realpath(path.c_str(), dummy))
mooseError("Failed to get real path for ", path);
#endif
if (PetscGetRealPath(path.c_str(), dummy))
mooseError("Failed to get real path for ", path);

return dummy;
#else
#ifndef __WIN32__
Expand Down
11 changes: 11 additions & 0 deletions test/tests/misc/realpath_exception/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Tests]
design = 'Parser.md'
issues = '#15718'

[./except01]
type = RunException
input = not_exist.i
expect_err = 'Failed to get real path for'
requirement = "The system shall print an understandable message when a user-specified path/file does not exist."
[../]
[]

0 comments on commit c2b0b58

Please sign in to comment.