Add better error handling.
Also now doesn't do anything if there's no input
This commit is contained in:
parent
d00b0f4c0e
commit
69797e58cb
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation";
|
import Operation from "../Operation";
|
||||||
|
import OperationError from "../errors/OperationError";
|
||||||
import {FORMATS, convertCoordinates} from "../lib/ConvertCoordinates";
|
import {FORMATS, convertCoordinates} from "../lib/ConvertCoordinates";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +38,6 @@ class ConvertCoordinateFormat extends Operation {
|
|||||||
"Auto",
|
"Auto",
|
||||||
"Direction Preceding",
|
"Direction Preceding",
|
||||||
"Direction Following",
|
"Direction Following",
|
||||||
"Space",
|
|
||||||
"\\n",
|
"\\n",
|
||||||
"Comma",
|
"Comma",
|
||||||
"Semi-colon",
|
"Semi-colon",
|
||||||
@ -83,8 +83,17 @@ class ConvertCoordinateFormat extends Operation {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const [inFormat, inDelim, outFormat, outDelim, incDirection, precision] = args;
|
if (input.replace(/[\s+]/g, "") !== "") {
|
||||||
return convertCoordinates(input, inFormat, inDelim, outFormat, outDelim, incDirection, precision);
|
const [inFormat, inDelim, outFormat, outDelim, incDirection, precision] = args;
|
||||||
|
try {
|
||||||
|
const result = convertCoordinates(input, inFormat, inDelim, outFormat, outDelim, incDirection, precision);
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
throw new OperationError(error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user