Repository navigation
How do I properly throw OperationError? #2861
|
I'm creating a module for CyberChef, and I want it to throw an OperationError. Currently, my line of code that throws the error looks like this:
(I should note this is the same line of code that throws an error without issue in the Bifid Cipher operations.) However, the error that ends up thrown is instead "undefined," and I can't tell why. I assume there's something else I need to update somewhere, but I don't know where to look for that. |
Replies: 2 comments
|
The Your fork currently has: import Operation from "../Operation.mjs";
import OperationError from "../Operation.mjs";Change the second line to: import OperationError from "../errors/OperationError.mjs";At the moment, No other registration or error configuration is needed. This is the same import used by the Bifid operations. Relevant source: the two incorrect imports in the fork, the real |
|
A bit of a shock I missed that for as long as I did... Thank you! |
The
throwstatement is correct. The problem is the import inTrifidCipherEncode.mjs.Your fork currently has:
Change the second line to:
At the moment,
new OperationError(...)is actually constructing another instance of the ordinaryOperationclass. That constructor ignores the string and does not create anError.message. Because the thrown object is not a realOperationError, CyberChef enters its generic error path and formatse.message, producingundefined.No other registration or error configuration is needed. This is the same import used…