New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update CostAndUsageReports.ts with try/catch error handling to enable unknown data to be gracefully handled #1226
base: changeset-release/trunk
Are you sure you want to change the base?
Conversation
1: Wrapped the processing of each row (both from inputData and unknownRows) inside a try-catch block. 2: In case of an error, log the problematic row along with the error message to the console.
af210f5
to
ddd42ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a great start @bendemora! i have a few questions on the location of the error handling itself and if the issue you are facing would actually lead to the catch blocks.
Also as an FYI - currently this PR is aiming to merge into cloud-carbon-footprint:changeset-release/trunk
. This should just be cloud-carbon-footprint:trunk
.
Thank you for taking the time to create this PR!
@@ -156,58 +156,67 @@ export default class CostAndUsageReports { | |||
getEstimatesFromInputData( | |||
inputData: LookupTableInput[], | |||
): LookupTableOutput[] { | |||
const result: LookupTableOutput[] = [] | |||
const unknownRows: CostAndUsageReportsRow[] = [] | |||
const result: LookupTableOutput[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can undo these changes where you add the semi-colons. It may not play well with the linter
co2e: footprintEstimate.co2e, | ||
}); | ||
} | ||
} catch (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you confirm that this will in fact reach the catch block? i am not sure that the issue here would actually trigger an error, however, I may be wrong.
kilowattHours: footprintEstimate.kilowattHours, | ||
co2e: footprintEstimate.co2e, | ||
}); | ||
} catch (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thought as above. I think if the error we are trying to fix is the NaN issue, we may be better to error handle at the root where the arithmetic occurs to aggregate the results. I could also see this potentially being console warnings.
ddd42ec
to
0fc7345
Compare
3d6575f
to
edcf5af
Compare
bedf1f0
to
d4ba421
Compare
Hi @bendemora have you had any chance to look at the requested changes / questions? |
f1cdf98
to
a2e9a7b
Compare
Hey Cameron,
Really sorry I've not had the ability to put work aside and spend time
trying to code (it's been a really long time since I last wrote any
software, so I had a go at this but it's unsurprising that my approach was
wrong)
Your thoughts on how to improve (or really, introduce) error handling here
would be welcome.
Cheers,
Ben
…On Thu, 12 Oct 2023 at 19:53, Cam Casher ***@***.***> wrote:
Hi @bendemora <https://github.com/bendemora> have you had any chance to
look at the requested changes / questions?
—
Reply to this email directly, view it on GitHub
<#1226 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AH3BXV6KNVQXJJARC5WITK3X7A4DBAVCNFSM6AAAAAA35SSX7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRQGIYDENZSGI>
.
You are receiving this because you were mentioned.Message ID:
<cloud-carbon-footprint/cloud-carbon-footprint/pull/1226/c1760202722@
github.com>
|
1af795e
to
dacc958
Compare
537e3e0
to
2991807
Compare
ffcd379
to
40bb0d7
Compare
25bc544
to
083e8ea
Compare
5310044
to
818521c
Compare
Within the getEstimatesFromInputData() function (line 156 onwards):
1: Wrapped the processing of each row (both from inputData and unknownRows) inside a try-catch block.
2: In case of an error, log the problematic row along with the error message to the console.
Description of Change
Write a brief but concise description of the changes you have made while also making sure to link the relevant issue number to this PR ( e.g. fixes #ISSUE-NUMBER - optional short description)
fixes ISSUE 1223
Checklist
(Please refrain from using
--no-verify
)(Determine version update using Semantic Versioning)
Notes
Additional information relevant to the changes
© 2021 Thoughtworks, Inc.