Throw ExcludedOperationError when excluded operation is called from API

This commit is contained in:
d98762625 2018-08-31 14:43:14 +01:00
parent 7c9ebafd00
commit 96d5930f05
6 changed files with 143 additions and 8 deletions

View file

@ -11,6 +11,7 @@ import SyncDish from "./SyncDish";
import Recipe from "./Recipe";
import OperationConfig from "./config/OperationConfig.json";
import { sanitise } from "./apiUtils";
import ExludedOperationError from "../core/errors/ExcludedOperationError";
/**
@ -246,3 +247,19 @@ export function bake(operations){
return recipe.execute(dish);
};
}
/**
* Explain that the given operation is not included in the Node.js version.
* @param {String} name - name of operation
*/
export function explainExludedFunction(name) {
/**
* Throw new error type with useful message.
*/
const func = () => {
throw new ExludedOperationError(`Sorry, the ${name} operation is not available in the Node.js version of CyberChef.`);
};
// Add opName prop so Recipe can handle it, just like wrap does.
func.opName = name;
return func;
}