@basis-theory/basis-theory-reactor-formulas-sdk-js 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/basis-theory-reactor-formulas-sdk-js",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Javascript SDK for building Basis Theory reactor formulas",
5
5
  "repository": "https://github.com/Basis-Theory/basistheory-reactor-formulas-sdk-js",
6
6
  "main": "src/index.js",
@@ -6,6 +6,15 @@ const sanitizeErrors = (errors) => {
6
6
 
7
7
  if (Array.isArray(errors)) {
8
8
  sanitizedErrors['error'] = errors;
9
+ } else if (errors instanceof Error) {
10
+ if (errors.message) {
11
+ sanitizedErrors['error'] = [errors.message];
12
+ } else if (errors.name !== 'Error') {
13
+ // "Error" is not helpful as a message
14
+ sanitizedErrors['error'] = [errors.name];
15
+ } else {
16
+ sanitizedErrors['error'] = [fallbackErrorMessage];
17
+ }
9
18
  } else if (typeof errors === 'object') {
10
19
  for (const property in errors) {
11
20
  if (Array.isArray(errors[property])) {
@@ -1,10 +1,11 @@
1
1
  const BasisTheoryReactorError = require('./BasisTheoryReactorError');
2
2
 
3
3
  class InvalidReactorFormulaError extends BasisTheoryReactorError {
4
- constructor(message) {
4
+ constructor(errors) {
5
5
  super({
6
- message,
6
+ message: 'Invalid Reactor Formula',
7
7
  status: 422,
8
+ errors,
8
9
  });
9
10
  this.name = 'InvalidReactorFormulaError';
10
11
  }