Skip to content

Error handling

The application throws nested errors, ranging from functional to technical.

Example of an invalid KAS credential error during decryption:

bash
[SdsdkError: ZTDF encryption failed] {
  cause: FetchingError: fetching error
      at wo.queryWithApiKeyCredentials (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:35492)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async ic.encryptDek (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:87058)
      ... 5 lines matching cause stack trace ...
      at async $c.encrypt (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:109031)
      at async <anonymous> (/home/***/src/encrypt.ts:6:18) {
    cause: HttpError: HTTP Error 401: Unauthorized - {"code":401,"message":"Kas Encrypt route call failed. Please contact your administrator.","details":"2001026,2006003,1014001,2005006"}
        at wo.sendRequest (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:36782)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
        at async wo.queryWithApiKeyCredentials (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:35428)
        at async ic.encryptDek (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:87058)
        at async sc.wrapSym (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:88503)
        at async sc.wrapWithSingleKas (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:88266)
        at async Promise.all (index 0)
        at async sc.wrap (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:87612)
        at async Pc.execute (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:108045)
        at async $c.encrypt (file:///home/***/node_modules/sdsdk/dist/sdsdk.mjs:14:109031) {
      status: 401,
      statusText: 'Unauthorized',
      body: '{"code":401,"message":"Kas Encrypt route call failed. Please contact your administrator.","details":"2001026,2006003,1014001,2005006"}'
    }
  }
}

All errors thrown by the Stormshield SDK are SdsdkError. These errors may have causes that add context to the generic SdsdkError. The Stormshield SDK exposes the following errors:

Error class nameDescription
SdsdkErrorGeneric error thrown by methods of the Sdsdk class
SdsdkValidationErrorValidation error
UnexpectedErrorAn unexpected error occurred in the Stormshield SDK
UnsupportedAlgorithmThe algorithm is not supported by the Stormshield SDK
FetchingErrorError occurred while fetching data
CryptographyErrorError occurred during cryptographic operations
JwsSignerErrorError occurred while signing a JWS message
JwsVerifyErrorError occurred while verifying a JWS message
CanonicalizerErrorError occurred during canonicalization process
InvalidAssertionIntegrityErrorAssertion integrity check failed
UnwrapDekErrorError occurred while unwrapping DEK
InvalidBase64ErrorInvalid Base64 encoding detected
NetworkErrorNetwork communication error occurred
ParsingErrorError occurred while parsing data
InvalidFetcherInvalid fetcher configuration or implementation
EncryptionErrorError occurred during encryption process
DecryptionErrorError occurred during decryption process
KeyPairGenerationErrorError occurred while generating a key pair
SigningErrorError occurred while signing data
SignatureVerificationErrorError occurred while verifying a signature
KeyImportErrorError occurred while importing a key
RandomGenerationErrorError occurred while generating random data
UuidGenerationErrorError occurred while generating a UUID
HashingErrorError occurred during hashing process