-
Notifications
You must be signed in to change notification settings - Fork 1
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 reporting functions to include a partial context in the error #28
Conversation
3f049db
to
7052e7e
Compare
7cdbfae
to
bc0b386
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.
Pull Request Overview
This PR updates the reporting functions to include a partial context in the error by introducing new types and adding an option to change reporting behavior when transitioning a draft trace to active. Key changes include:
- Addition of new types (PartialPossibleTraceContext and ReportErrorFn) in types.ts.
- Updates in Tracer.ts and Trace.ts to optionally pass an error-reporting context via opts.
- Adjustments in tests to validate the new reporting behavior.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/v3/types.ts | Introduced new types supporting partial error context |
src/v3/Tracer.ts | Updated error reporting logic to conditionally use error vs warning |
src/v3/TraceManagerWithDraft.test.ts | Updated tests to reflect new reporting behavior and context checks |
src/v3/TraceManager.ts | Adjusted type definitions for reportWarningFn |
src/v3/Trace.ts | Updated transitionDraftToActive to pass opts and report context |
Comments suppressed due to low confidence (2)
src/v3/Tracer.ts:109
- [nitpick] Consider addressing the underlying type issue instead of using @ts-expect-error. Updating type definitions could eliminate the need for suppressing errors.
// @ts-expect-error TS doesn't like this type for some reason
src/v3/Trace.ts:1074
- [nitpick] Evaluate the root cause of the TypeScript complaint and update the type definitions accordingly to remove the need for @ts-expect-error.
// @ts-expect-error TS doesn't like this type for some reason
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.
looks good, left some notes!
did we cover all uses of reportErrorFn?
yup! should have 🙏 ! |
012ae70
to
c8e0a25
Compare
…iming-hooks into report-error-fns # Conflicts: # src/v3/Trace.ts
Co-authored-by: Cynthia Ma <[email protected]>
fac558b
to
e7a6ee8
Compare
@@ -929,8 +931,12 @@ export class Trace< | |||
VariantsT | |||
> { | |||
if (!this.input.relatedTo) { | |||
throw new Error( | |||
"Tried to access trace's activeInput, but the trace was never provided a 'relatedTo' input value", | |||
this.traceUtilities.reportErrorFn( |
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.
small clean up: replacing throw error with this.traceUtilities.reportErrorFn
@@ -1250,7 +1313,11 @@ export class Trace< | |||
this.applyDefinitionModifications(inputAndDefinitionModifications) | |||
|
|||
this.wasActivated = true | |||
this.stateMachine.emit('onMakeActive', undefined) | |||
|
|||
if (isDraft) { |
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.
only drafts can switch the state to active
new Error( | ||
"Tried to access trace's activeInput, but the trace was never provided a 'relatedTo' input value", | ||
), | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
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.
this was the best way we can address this time for the time being
@@ -97,29 +98,8 @@ export class Tracer< | |||
} | |||
|
|||
interrupt = ({ error }: { error?: Error } = {}) => { | |||
const trace: |
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.
consolidated these into getCurrentTraceOrWarn
@@ -153,28 +133,8 @@ export class Tracer< | |||
VariantsT | |||
>, | |||
): void => { | |||
const trace: |
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.
consolidated these into getCurrentTraceOrWarn
): void => { | ||
const trace = this.getCurrentTraceOrWarn() |
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.
the flow is we check if we have a current trace, if not, we do a blanket warning (not customizable)
once a current trace is confirmed, and we transitionDraftToActive
, then we can use the new optional draft options (previouslyActivatedBehavior and invalidRelatedToBehavior)
this.traceUtilities.reportWarningFn( | ||
new Error( | ||
`You are trying to initialize a trace that has already been initialized before (${trace.definition.name}).`, |
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.
whoops, originally had the wrong message
} | ||
|
||
// verify that trace is the same definition as the Tracer's definition | ||
if (trace.sourceDefinition !== this.definition) { | ||
this.traceUtilities.reportWarningFn( | ||
new Error( | ||
`You are trying to initialize a trace that is not the same definition as the Tracer's definition is different.`, |
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.
whoops, originally had the wrong message
Co-authored-by: Evan Jenkins <[email protected]>
🎉 This PR is included in version 2.4.0-next.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
descoped: