/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2014 OpenFOAM Foundation Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "error.H" #include "StringStream.H" #include "fileName.H" #include "dictionary.H" #include "JobInfo.H" #include "Pstream.H" #include "foamVersion.H" #include "OSspecific.H" // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // void Foam::error::warnAboutAge(const char* what, const int version) { if (version <= 0) { // No warning for 0 (unversioned) or -ve values (silent versioning) } else if (version < 1000) { // Warning for things that predate the YYMM versioning // (eg, 240 for version 2.4) std::cerr << " This " << what << " is considered to be VERY old!\n" << std::endl; } else if (version < foamVersion::api) { const int months = ( // YYMM -> months (12 * (foamVersion::api/100) + (foamVersion::api % 100)) - (12 * (version/100) + (version % 100)) ); std::cerr << " This " << what << " is deemed to be " << months << " months old.\n" << std::endl; } // No warning for (foamVersion::api < version). // We use this to denote future expiry dates of transition features. } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::error::error(const string& title) : std::exception(), messageStream(title, messageStream::FATAL), functionName_("unknown"), sourceFileName_("unknown"), sourceFileLineNumber_(0), throwExceptions_(false), messageStreamPtr_(new OStringStream()) { if (!messageStreamPtr_->good()) { Perr<< nl << "error::error(const string& title) : cannot open error stream" << endl; exit(1); } } Foam::error::error(const dictionary& errDict) : std::exception(), messageStream(errDict), functionName_(errDict.get("functionName")), sourceFileName_(errDict.get("sourceFileName")), sourceFileLineNumber_(errDict.get