ootk-core
Version:
Orbital Object Toolkit. A modern typed replacement for satellite.js including SGP4 propagation, TLE parsing, Sun and Moon calculations, and more.
44 lines • 2.03 kB
JavaScript
/**
* Improved error handling for SGP4
*/
// Define specific error types
export var Sgp4ErrorCode;
(function (Sgp4ErrorCode) {
Sgp4ErrorCode[Sgp4ErrorCode["NO_ERROR"] = 0] = "NO_ERROR";
Sgp4ErrorCode[Sgp4ErrorCode["MEAN_ELEMENTS_INVALID"] = 1] = "MEAN_ELEMENTS_INVALID";
Sgp4ErrorCode[Sgp4ErrorCode["MEAN_MOTION_NEGATIVE"] = 2] = "MEAN_MOTION_NEGATIVE";
Sgp4ErrorCode[Sgp4ErrorCode["PERT_ELEMENTS_INVALID"] = 3] = "PERT_ELEMENTS_INVALID";
Sgp4ErrorCode[Sgp4ErrorCode["SEMI_LATUS_RECTUM_NEGATIVE"] = 4] = "SEMI_LATUS_RECTUM_NEGATIVE";
Sgp4ErrorCode[Sgp4ErrorCode["EPOCH_ELEMENTS_SUBORBITAL"] = 5] = "EPOCH_ELEMENTS_SUBORBITAL";
Sgp4ErrorCode[Sgp4ErrorCode["SATELLITE_DECAYED"] = 6] = "SATELLITE_DECAYED"; // satellite has decayed
})(Sgp4ErrorCode || (Sgp4ErrorCode = {}));
// Error class for SGP4 errors
export class Sgp4Error extends Error {
code;
constructor(code, message) {
super(message ?? Sgp4Error.getDefaultMessage(code));
this.name = 'Sgp4Error';
this.code = code;
}
static getDefaultMessage(code) {
switch (code) {
case Sgp4ErrorCode.NO_ERROR:
return 'No error';
case Sgp4ErrorCode.MEAN_ELEMENTS_INVALID:
return 'Mean elements invalid: eccentricity out of range or semi-major axis too small';
case Sgp4ErrorCode.MEAN_MOTION_NEGATIVE:
return 'Mean motion is negative';
case Sgp4ErrorCode.PERT_ELEMENTS_INVALID:
return 'Perturbed elements invalid: eccentricity out of range';
case Sgp4ErrorCode.SEMI_LATUS_RECTUM_NEGATIVE:
return 'Semi-latus rectum is negative';
case Sgp4ErrorCode.EPOCH_ELEMENTS_SUBORBITAL:
return 'Epoch elements are sub-orbital';
case Sgp4ErrorCode.SATELLITE_DECAYED:
return 'Satellite has decayed';
default:
return `Unknown error code: ${code}`;
}
}
}
//# sourceMappingURL=sgp4-error.js.map