File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
NaifStatus.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "NaifStatus.h"
8 
9 #include <iostream>
10 
11 #include <SpiceUsr.h>
12 
13 #include "IException.h"
14 #include "IString.h"
15 #include "Pvl.h"
16 #include "PvlToPvlTranslationManager.h"
17 
18 namespace Isis {
19  bool NaifStatus::initialized = false;
20 
28  void NaifStatus::CheckErrors(bool resetNaif) {
29  if(!initialized) {
30  SpiceChar returnAct[32] = "RETURN";
31  SpiceChar printAct[32] = "NONE";
32  erract_c("SET", sizeof(returnAct), returnAct); // Reset action to return
33  errprt_c("SET", sizeof(printAct), printAct); // ... and print nothing
34  initialized = true;
35  }
36 
37  // Do nothing if NAIF didn't fail
38  //getmsg_c("", 0, NULL);
39  if(!failed_c()) return;
40 
41  // This method has been documented with the information provided
42  // from the NAIF documentation at:
43  // naif/cspice61/packages/cspice/doc/html/req/error.html
44 
45 
46  // This message is a character string containing a very terse, usually
47  // abbreviated, description of the problem. The message is a character
48  // string of length not more than 25 characters. It always has the form:
49  // SPICE(...)
50  // Short error messages used in CSPICE are CONSTANT, since they are
51  // intended to be used in code. That is, they don't contain any data which
52  // varies with the specific instance of the error they indicate.
53  // Because of the brief format of the short error messages, it is practical
54  // to use them in a test to determine which type of error has occurred.
55  const int SHORT_DESC_LEN = 26;
56  SpiceChar naifShort[SHORT_DESC_LEN];
57  getmsg_c("SHORT", SHORT_DESC_LEN, naifShort);
58 
59  // This message may be up to 1840 characters long. The CSPICE error handling
60  // mechanism makes no use of its contents. Its purpose is to provide human-readable
61  // information about errors. Long error messages generated by CSPICE routines often
62  // contain data relevant to the specific error they describe.
63  const int LONG_DESC_LEN = 1841;
64  SpiceChar naifLong[LONG_DESC_LEN];
65  getmsg_c("LONG", LONG_DESC_LEN, naifLong);
66 
67  // Search for known naif errors...
68  QString errMsg;
69 
70  Pvl error;
71  PvlGroup errorDescription("ErrorDescription");
72  errorDescription.addKeyword(PvlKeyword("ShortMessage", naifShort));
73  errorDescription.addKeyword(PvlKeyword("LongMessage", naifLong));
74  error.addGroup(errorDescription);
75 
76  PvlToPvlTranslationManager trans(error, "$ISISROOT/appdata/translations/NaifErrors.trn");
77 
78  try {
79  errMsg = trans.Translate("ShortMessage");
80  }
81  catch(IException &) {
82  errMsg = "An unknown NAIF error has been encountered.";
83  }
84 
85  try {
86  errMsg += " " + trans.Translate("LongMessage");
87  }
88  catch(IException &) {
89  }
90 
91  // Now process the error
92  if(resetNaif) {
93  reset_c();
94  }
95 
96  errMsg += " The short explanation ";
97  errMsg += "provided by NAIF is [" + QString(naifShort) + "]. ";
98  errMsg += "The Naif error is [" + QString(naifLong) + "]";
99 
100  throw IException(IException::Unknown, errMsg, _FILEINFO_);
101  }
102 }
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::PvlContainer::addKeyword
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
Definition: PvlContainer.cpp:202
Isis::IException::Unknown
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:118
Isis::PvlToPvlTranslationManager::Translate
virtual QString Translate(QString translationGroupName, int findex=0)
Returns a translated value.
Definition: PvlToPvlTranslationManager.cpp:107
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::NaifStatus::CheckErrors
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:28
Isis::PvlToPvlTranslationManager
Allows applications to translate simple text files.
Definition: PvlToPvlTranslationManager.h:65
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::PvlObject::addGroup
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Definition: PvlObject.h:186
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:55