mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Changed all error returns to OperationErrors
This commit is contained in:
parent
b3ee251ee3
commit
2e4f5b7070
25 changed files with 88 additions and 35 deletions
|
@ -7,6 +7,7 @@
|
|||
import Operation from "../Operation";
|
||||
import moment from "moment-timezone";
|
||||
import {UNITS} from "../lib/DateTime";
|
||||
import OperationError from "../errors/OperationError";
|
||||
|
||||
/**
|
||||
* To UNIX Timestamp operation
|
||||
|
@ -47,6 +48,8 @@ class ToUNIXTimestamp extends Operation {
|
|||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*
|
||||
* @throws {OperationError} if unit unrecognised
|
||||
*/
|
||||
run(input, args) {
|
||||
const [units, treatAsUTC, showDateTime] = args,
|
||||
|
@ -63,7 +66,7 @@ class ToUNIXTimestamp extends Operation {
|
|||
} else if (units === "Nanoseconds (ns)") {
|
||||
result = d.valueOf() * 1000000;
|
||||
} else {
|
||||
throw "Unrecognised unit";
|
||||
throw new OperationError("Unrecognised unit");
|
||||
}
|
||||
|
||||
return showDateTime ? `${result} (${d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss")} UTC)` : result.toString();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue