Skip to content

Commit

Permalink
Acoustic - Improve Error Messaging (#1795)
Browse files Browse the repository at this point in the history
* Resolve generated-types.ts

* resolve 'variant=null' exception

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* remove fullstory, yet again

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* Resolve differences btwn main

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* resolve Unexpected Exception-attribute with null values

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* resolve unexpected exception, update tests,

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* resolve renamed var

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* final tidyup,

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* remove gitignore add

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* Bubble Up/Correct Nesting Depth Fail

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* Correct Throw/Catch, improve config check

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* resolve nesting depth exception bubble-up

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

* Resolve Tests

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>

---------

Signed-off-by: kwlandry-acoustic <kip.landry@acoustic.com>
  • Loading branch information
KWLandry-acoustic authored Jan 16, 2024
1 parent 92d3492 commit 95f6c6a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Send Events Action', () => {
s3_secret: 'secret',
s3_region: 'us-east-1',
s3_bucket_accesspoint_alias: 'my-bucket',
fileNamePrefix: 'prefix'
fileNamePrefix: 'prefix_'
} as Settings

test('perform ValidateSettings call with valid payload and settings', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const validS3Settings = {
s3_secret: 'secret',
s3_region: 'us-east-1',
s3_bucket_accesspoint_alias: 'my-bucket',
fileNamePrefix: 'prefix'
fileNamePrefix: 'prefix_'
}

describe('validateSettings', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import get from 'lodash/get'
export function parseSections(section: { [key: string]: string }, nestDepth: number) {
const parseResults: { [key: string]: string } = {}

if (nestDepth > 10)
throw new IntegrationError(
'Event data exceeds nesting depth. Use Mapping to flatten the data to no more than 3 levels deep',
'NESTING_DEPTH_EXCEEDED',
400
)
if (nestDepth > 10) throw new IntegrationError('Event data exceeds nesting depth.', 'NESTING_DEPTH_EXCEEDED', 400)

try {
if (section === null) section = { null: '' }
Expand All @@ -31,11 +26,19 @@ export function parseSections(section: { [key: string]: string }, nestDepth: num
}
}
} catch (e) {
throw new IntegrationError(
`Unexpected Exception while parsing Event payload.\n ${e}`,
'UNEXPECTED_EVENT_PARSING_EXCEPTION',
400
)
const ie = e as IntegrationError
if (ie.code === 'NESTING_DEPTH_EXCEEDED')
throw new IntegrationError(
'Event data exceeds nesting depth. Use Mapping to flatten data structures to no more than 3 levels deep',
'NESTING_DEPTH_EXCEEDED',
400
)
else
throw new IntegrationError(
`Unexpected Exception while parsing Event payload.\n ${e}`,
'UNEXPECTED_EVENT_PARSING_EXCEPTION',
400
)
}
return parseResults
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,25 @@ function validateSettings(settings: Settings) {
}

if (!settings.fileNamePrefix) {
throw new IntegrationError('Missing Customer Prefix', 'MISSING_CUSTOMER_PREFIX', 400)
throw new IntegrationError(
'Missing Customer Prefix. Customer Prefix should be of the form of 4-5 characters followed by an underscore character',
'MISSING_CUSTOMER_PREFIX',
400
)
}
if (!settings.fileNamePrefix.endsWith('_')) {
throw new IntegrationError(
'Invalid Customer Prefix. Customer Prefix must end with an underscore character "_". ',
'INVALID_CUSTOMER_PREFIX',
400
)
}
if (settings.fileNamePrefix === 'customer_org_') {
throw new IntegrationError(
'Unedited Customer Prefix. Customer Prefix remains as the default value, must edit and provide a valid Customer prefix (4-5 characters) followed by an underscore',
'INVALID_CUSTOMER_PREFIX',
400
)
}
}

Expand Down

0 comments on commit 95f6c6a

Please sign in to comment.