Skip to content

Commit

Permalink
Rename function to unexport it
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Apr 23, 2024
1 parent fc31911 commit 8b9e130
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions common/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func (b *Browser) NewContext(opts goja.Value) (*BrowserContext, error) {

if b.context != nil {
err := errors.New("existing browser context must be closed before creating a new one")
SpanRecordError(span, "browserContext already exists", err)
spanRecordError(span, "browserContext already exists", err)
return nil, err
}

Expand All @@ -560,21 +560,21 @@ func (b *Browser) NewContext(opts goja.Value) (*BrowserContext, error) {
b.logger.Debugf("Browser:NewContext", "bctxid:%v", browserContextID)
if err != nil {
err := fmt.Errorf("creating browser context ID %s: %w", browserContextID, err)
SpanRecordError(span, "browserContext creation in Chrome failed", err)
spanRecordError(span, "browserContext creation in Chrome failed", err)
return nil, err
}

browserCtxOpts := NewBrowserContextOptions()
if err := browserCtxOpts.Parse(b.ctx, opts); err != nil {
err := fmt.Errorf("parsing newContext options: %w", err)
SpanRecordError(span, "new browserContext options parsing failed", err)
spanRecordError(span, "new browserContext options parsing failed", err)
return nil, err
}

browserCtx, err := NewBrowserContext(b.ctx, b, browserContextID, browserCtxOpts, b.logger)
if err != nil {
err := fmt.Errorf("new context: %w", err)
SpanRecordError(span, "new browserContext creation failed", err)
spanRecordError(span, "new browserContext creation failed", err)
return nil, err
}

Expand All @@ -593,13 +593,13 @@ func (b *Browser) NewPage(opts goja.Value) (*Page, error) {
browserCtx, err := b.NewContext(opts)
if err != nil {
err := fmt.Errorf("new page: %w", err)
SpanRecordError(span, "new browserContext creation failed", err)
spanRecordError(span, "new browserContext creation failed", err)
return nil, err
}

page, err := browserCtx.NewPage()
if err != nil {
SpanRecordError(span, "new page creation failed", err)
spanRecordError(span, "new page creation failed", err)
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion common/browser_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (b *BrowserContext) NewPage() (*Page, error) {
p, err := b.browser.newPageInContext(b.id)
if err != nil {
err := fmt.Errorf("creating new page in browser context: %w", err)
SpanRecordError(span, "failed to create a new page", err)
spanRecordError(span, "failed to create a new page", err)
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion common/element_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ func (h *ElementHandle) Screenshot(
buf, err := s.screenshotElement(h, opts)
if err != nil {
err := fmt.Errorf("taking screenshot of elementHandle: %w", err)
SpanRecordError(span, "failed to take screenshot", err)
spanRecordError(span, "failed to take screenshot", err)
return nil, err
}

Expand Down
6 changes: 3 additions & 3 deletions common/locator.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (l *Locator) Click(opts *FrameClickOptions) error {

if err := l.click(opts); err != nil {
err := fmt.Errorf("clicking on %q: %w", l.selector, err)
SpanRecordError(span, "click failed", err)
spanRecordError(span, "click failed", err)
return err
}

Expand Down Expand Up @@ -522,12 +522,12 @@ func (l *Locator) Type(text string, opts goja.Value) error {
copts := NewFrameTypeOptions(l.frame.defaultTimeout())
if err := copts.Parse(l.ctx, opts); err != nil {
err := fmt.Errorf("parsing type options: %w", err)
SpanRecordError(span, "type option parsing failed", err)
spanRecordError(span, "type option parsing failed", err)
return err
}
if err := l.typ(text, copts); err != nil {
err := fmt.Errorf("typing %q in %q: %w", text, l.selector, err)
SpanRecordError(span, "type failed", err)
spanRecordError(span, "type failed", err)
return err
}

Expand Down
18 changes: 9 additions & 9 deletions common/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ func (p *Page) Close(_ goja.Value) error {
add := runtime.RemoveBinding(webVitalBinding)
if err := add.Do(cdp.WithExecutor(p.ctx, p.session)); err != nil {
err := fmt.Errorf("internal error while removing binding from page: %w", err)
SpanRecordError(span, "close failed due to internal error", err)
spanRecordError(span, "close failed due to internal error", err)
return err
}

Expand All @@ -679,7 +679,7 @@ func (p *Page) Close(_ goja.Value) error {
}

err := fmt.Errorf("closing a page: %w", err)
SpanRecordError(span, "close failed", err)
spanRecordError(span, "close failed", err)
return err
}

Expand Down Expand Up @@ -832,7 +832,7 @@ func (p *Page) Goto(url string, opts *FrameGotoOptions) (*Response, error) {

resp, err := p.MainFrame().Goto(url, opts)
if err != nil {
SpanRecordError(span, "goto failed", err)
spanRecordError(span, "goto failed", err)
return nil, err
}

Expand Down Expand Up @@ -996,7 +996,7 @@ func (p *Page) Reload(opts goja.Value) (*Response, error) { //nolint:funlen,cycl
)
if err := parsedOpts.Parse(p.ctx, opts); err != nil {
err := fmt.Errorf("parsing reload options: %w", err)
SpanRecordError(span, "reload option parsing failed", err)
spanRecordError(span, "reload option parsing failed", err)
return nil, err
}

Expand Down Expand Up @@ -1024,7 +1024,7 @@ func (p *Page) Reload(opts goja.Value) (*Response, error) { //nolint:funlen,cycl
action := cdppage.Reload()
if err := action.Do(cdp.WithExecutor(p.ctx, p.session)); err != nil {
err := fmt.Errorf("reloading page: %w", err)
SpanRecordError(span, "reload failed", err)
spanRecordError(span, "reload failed", err)
return nil, err
}

Expand All @@ -1046,7 +1046,7 @@ func (p *Page) Reload(opts goja.Value) (*Response, error) { //nolint:funlen,cycl
case <-p.ctx.Done():
case <-timeoutCtx.Done():
err := wrapTimeoutError(timeoutCtx.Err())
SpanRecordError(span, "reload navigation timed out", err)
spanRecordError(span, "reload navigation timed out", err)
return nil, err
case data := <-ch:
event = data.(*NavigationEvent)
Expand All @@ -1064,7 +1064,7 @@ func (p *Page) Reload(opts goja.Value) (*Response, error) { //nolint:funlen,cycl
case <-lifecycleEvtCh:
case <-timeoutCtx.Done():
err := wrapTimeoutError(timeoutCtx.Err())
SpanRecordError(span, "reload lifecycle timed out", err)
spanRecordError(span, "reload lifecycle timed out", err)
return nil, err
}

Expand All @@ -1084,7 +1084,7 @@ func (p *Page) Screenshot(opts *PageScreenshotOptions, sp ScreenshotPersister) (
buf, err := s.screenshotPage(p, opts)
if err != nil {
err := fmt.Errorf("taking screenshot of page: %w", err)
SpanRecordError(span, "screenshot failed", err)
spanRecordError(span, "screenshot failed", err)
return nil, err
}

Expand Down Expand Up @@ -1256,7 +1256,7 @@ func (p *Page) WaitForNavigation(opts *FrameWaitForNavigationOptions) (*Response

resp, err := p.frameManager.MainFrame().WaitForNavigation(opts)
if err != nil {
SpanRecordError(span, "waiting for navigation failed", err)
spanRecordError(span, "waiting for navigation failed", err)
return nil, err
}

Expand Down
4 changes: 2 additions & 2 deletions common/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ func TraceEvent(
return ctx, browsertrace.NoopSpan{}
}

// SpanRecordError will set the status of the span to error and record the
// spanRecordError will set the status of the span to error and record the
// error on the span. Check the documentation for trace.SetStatus and
// trace.RecordError for more details.
func SpanRecordError(span trace.Span, description string, err error) {
func spanRecordError(span trace.Span, description string, err error) {
span.SetStatus(codes.Error, description)
span.RecordError(err)
}

0 comments on commit 8b9e130

Please sign in to comment.