@wix/motion-edm-autogen-transformations
Advanced tools
Comparing version 1.46.0 to 1.47.0
@@ -8,2 +8,3 @@ "use strict"; | ||
var _lodash = require("lodash"); | ||
var _constants = require("../../../lib/constants"); | ||
var _ = require("../../.."); | ||
@@ -45,3 +46,7 @@ describe('transformError', () => { | ||
requestId, | ||
code: expectedErrorCodes[httpStatus] | ||
code: expectedErrorCodes[httpStatus], | ||
metadata: { | ||
errorType: _constants.ErrorType.System, | ||
httpStatusCode: httpStatus | ||
} | ||
}); | ||
@@ -59,3 +64,6 @@ }); | ||
message: 'System error occurred', | ||
code: 'UNKNOWN' | ||
code: 'UNKNOWN', | ||
metadata: { | ||
errorType: _constants.ErrorType.System | ||
} | ||
}); | ||
@@ -76,3 +84,6 @@ }); | ||
code: 'UNKNOWN', | ||
runtimeError: ambassadorHTTPError.runtimeError | ||
runtimeError: ambassadorHTTPError.runtimeError, | ||
metadata: { | ||
errorType: _constants.ErrorType.System | ||
} | ||
}); | ||
@@ -125,2 +136,6 @@ }); | ||
} | ||
}, | ||
metadata: { | ||
errorType: _constants.ErrorType.User, | ||
httpStatusCode: ambassadorHTTPError.httpStatus | ||
} | ||
@@ -181,2 +196,6 @@ }); | ||
} | ||
}, | ||
metadata: { | ||
errorType: _constants.ErrorType.User, | ||
httpStatusCode: ambassadorHTTPError.httpStatus | ||
} | ||
@@ -226,2 +245,6 @@ }); | ||
} | ||
}, | ||
metadata: { | ||
errorType: _constants.ErrorType.User, | ||
httpStatusCode: ambassadorHTTPError.httpStatus | ||
} | ||
@@ -265,2 +288,6 @@ }); | ||
} | ||
}, | ||
metadata: { | ||
errorType: _constants.ErrorType.User, | ||
httpStatusCode: ambassadorHTTPError.httpStatus | ||
} | ||
@@ -314,2 +341,5 @@ }); | ||
} | ||
}, | ||
metadata: { | ||
errorType: _constants.ErrorType.User | ||
} | ||
@@ -362,2 +392,6 @@ }); | ||
} | ||
}, | ||
metadata: { | ||
errorType: _constants.ErrorType.User, | ||
httpStatusCode: httpStatus | ||
} | ||
@@ -392,2 +426,6 @@ }); | ||
} | ||
}, | ||
metadata: { | ||
errorType: _constants.ErrorType.User, | ||
httpStatusCode: httpStatus | ||
} | ||
@@ -421,2 +459,6 @@ }); | ||
} | ||
}, | ||
metadata: { | ||
errorType: _constants.ErrorType.User, | ||
httpStatusCode: httpStatus | ||
} | ||
@@ -423,0 +465,0 @@ }); |
@@ -10,2 +10,3 @@ "use strict"; | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _constants = require("../../constants"); | ||
var _violationsWithRenamedFields = require("./violationsWithRenamedFields"); | ||
@@ -51,2 +52,8 @@ const { | ||
const isApplicationError = ambassadorHTTPError => has(ambassadorHTTPError, 'response.details.applicationError') || isClientError(ambassadorHTTPError.httpStatus); | ||
const buildErrorMetadata = (errorType, httpStatusCode) => { | ||
return { | ||
errorType, | ||
httpStatusCode | ||
}; | ||
}; | ||
const buildValidationError = (ambassadorHTTPError, transformation, argumentNames) => { | ||
@@ -74,2 +81,3 @@ const { | ||
}; | ||
const metadata = buildErrorMetadata(_constants.ErrorType.User, ambassadorHTTPError.httpStatus); | ||
return buildError({ | ||
@@ -81,3 +89,4 @@ message: toYamlString({ | ||
extraProperties: { | ||
details | ||
details, | ||
metadata | ||
} | ||
@@ -89,2 +98,3 @@ }); | ||
const hasEmptyDetails = isEqual(get(ambassadorHTTPError, 'response.details', {}), {}); | ||
const metadata = buildErrorMetadata(_constants.ErrorType.User, ambassadorHTTPError.httpStatus); | ||
if (hasEmptyDetails) { | ||
@@ -104,3 +114,4 @@ const details = { | ||
extraProperties: { | ||
details | ||
details, | ||
metadata | ||
} | ||
@@ -127,3 +138,4 @@ }); | ||
extraProperties: { | ||
details | ||
details, | ||
metadata | ||
} | ||
@@ -135,2 +147,3 @@ }); | ||
const message = ambassadorHTTPError.requestId ? `System error occurred, request-id: ${ambassadorHTTPError.requestId}` : 'System error occurred'; | ||
const metadata = buildErrorMetadata(_constants.ErrorType.System, ambassadorHTTPError.httpStatus); | ||
return buildError({ | ||
@@ -141,2 +154,3 @@ message, | ||
code, | ||
metadata, | ||
...(ambassadorHTTPError.runtimeError && { | ||
@@ -143,0 +157,0 @@ runtimeError: ambassadorHTTPError.runtimeError |
@@ -5,2 +5,3 @@ import { anObject, aNumber, aRandomItemFrom, aRequestId, aString, } from '@wix/motion-runtime-test-context'; | ||
import { set, times, upperCase } from 'lodash'; | ||
import { ErrorType } from '../../../lib/constants'; | ||
import { transformError } from '../../..'; | ||
@@ -38,2 +39,3 @@ describe('transformError', () => { | ||
code: expectedErrorCodes[httpStatus], | ||
metadata: { errorType: ErrorType.System, httpStatusCode: httpStatus }, | ||
}); | ||
@@ -50,2 +52,3 @@ }); | ||
code: 'UNKNOWN', | ||
metadata: { errorType: ErrorType.System }, | ||
}); | ||
@@ -67,2 +70,3 @@ }); | ||
runtimeError: ambassadorHTTPError.runtimeError, | ||
metadata: { errorType: ErrorType.System }, | ||
}); | ||
@@ -103,2 +107,3 @@ }); | ||
}, | ||
metadata: { errorType: ErrorType.User, httpStatusCode: ambassadorHTTPError.httpStatus }, | ||
}); | ||
@@ -148,2 +153,3 @@ }); | ||
}, | ||
metadata: { errorType: ErrorType.User, httpStatusCode: ambassadorHTTPError.httpStatus }, | ||
}); | ||
@@ -189,2 +195,3 @@ }); | ||
}, | ||
metadata: { errorType: ErrorType.User, httpStatusCode: ambassadorHTTPError.httpStatus }, | ||
}); | ||
@@ -226,2 +233,3 @@ }); | ||
}, | ||
metadata: { errorType: ErrorType.User, httpStatusCode: ambassadorHTTPError.httpStatus }, | ||
}); | ||
@@ -278,2 +286,3 @@ }); | ||
}, | ||
metadata: { errorType: ErrorType.User }, | ||
}); | ||
@@ -323,2 +332,3 @@ }); | ||
}, | ||
metadata: { errorType: ErrorType.User, httpStatusCode: httpStatus }, | ||
}); | ||
@@ -351,2 +361,3 @@ }); | ||
}, | ||
metadata: { errorType: ErrorType.User, httpStatusCode: httpStatus }, | ||
}); | ||
@@ -375,2 +386,3 @@ }); | ||
}, | ||
metadata: { errorType: ErrorType.User, httpStatusCode: httpStatus }, | ||
}); | ||
@@ -377,0 +389,0 @@ }); |
@@ -5,2 +5,3 @@ import { constantCase } from 'constant-case'; | ||
import _ from 'lodash'; | ||
import { ErrorType } from '../../constants'; | ||
import { violationsWithRenamedFields } from './violationsWithRenamedFields'; | ||
@@ -39,2 +40,5 @@ const { get, has, forOwn, isEqual } = _; | ||
isClientError(ambassadorHTTPError.httpStatus); | ||
const buildErrorMetadata = (errorType, httpStatusCode) => { | ||
return { errorType, httpStatusCode }; | ||
}; | ||
const buildValidationError = (ambassadorHTTPError, transformation, argumentNames) => { | ||
@@ -55,5 +59,6 @@ const { details: { validationError: { fieldViolations }, }, } = ambassadorHTTPError.response; | ||
}; | ||
const metadata = buildErrorMetadata(ErrorType.User, ambassadorHTTPError.httpStatus); | ||
return buildError({ | ||
message: toYamlString({ message, details }), | ||
extraProperties: { details }, | ||
extraProperties: { details, metadata }, | ||
}); | ||
@@ -64,2 +69,3 @@ }; | ||
const hasEmptyDetails = isEqual(get(ambassadorHTTPError, 'response.details', {}), {}); | ||
const metadata = buildErrorMetadata(ErrorType.User, ambassadorHTTPError.httpStatus); | ||
if (hasEmptyDetails) { | ||
@@ -78,3 +84,3 @@ const details = { | ||
}), | ||
extraProperties: { details }, | ||
extraProperties: { details, metadata }, | ||
}); | ||
@@ -96,3 +102,3 @@ } | ||
message: toYamlString({ message: combinedMessage, details }), | ||
extraProperties: { details }, | ||
extraProperties: { details, metadata }, | ||
}); | ||
@@ -105,2 +111,3 @@ }; | ||
: 'System error occurred'; | ||
const metadata = buildErrorMetadata(ErrorType.System, ambassadorHTTPError.httpStatus); | ||
return buildError({ | ||
@@ -111,2 +118,3 @@ message, | ||
code, | ||
metadata, | ||
...(ambassadorHTTPError.runtimeError && { | ||
@@ -113,0 +121,0 @@ runtimeError: ambassadorHTTPError.runtimeError, |
{ | ||
"name": "@wix/motion-edm-autogen-transformations", | ||
"version": "1.46.0", | ||
"version": "1.47.0", | ||
"license": "UNLICENSED", | ||
@@ -54,5 +54,5 @@ "author": { | ||
"@types/node": "^14.0.0", | ||
"@wix/jest-yoshi-preset": "^6.89.0", | ||
"@wix/jest-yoshi-preset": "^6.91.1", | ||
"@wix/motion-runtime-test-context": "~1.0.0", | ||
"@wix/yoshi-flow-library": "^6.89.0", | ||
"@wix/yoshi-flow-library": "^6.91.1", | ||
"dedent-js": "~1.0.0", | ||
@@ -77,3 +77,3 @@ "eslint-plugin-simple-import-sort": "^10.0.0", | ||
}, | ||
"falconPackageHash": "941a2bf147224199d40116cbc1f5b997fd63935211042f62a7510bd1" | ||
"falconPackageHash": "8bd4cbf7132ba2e1f50524eb6e49f42c31eeec778c3f74d120aaea64" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
408337
110
3629