Skip to content

Commit

Permalink
refactor: rm Bug struct
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-tekuri committed Jun 3, 2024
1 parent 4e06fd7 commit 40de0fb
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
5 changes: 1 addition & 4 deletions compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,7 @@ func (c *Compiler) doCompile(up urlPtr) (*Schema, error) {
if err := c.roots.ensureSubschema(sch.up); err != nil {
return nil, err
}
r, ok := c.roots.roots[sch.up.url]
if !ok {
return nil, &Bug{"orLoad did not add"}
}
r := c.roots.roots[sch.up.url]
v, err := sch.up.lookup(r.doc)
if err != nil {
return nil, err
Expand Down
6 changes: 1 addition & 5 deletions root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ type root struct {
}

func (r *root) rootResource() *resource {
res, ok := r.resources[""]
if !ok {
panic(&Bug{fmt.Sprintf("root resource should exist for %q", r.url)})
}
return res
return r.resources[""]
}

func (r *root) resource(ptr jsonPointer) *resource {
Expand Down
11 changes: 0 additions & 11 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,17 +445,6 @@ func (e *SchemaValidationError) Error() string {

// --

//nolint:errname
type Bug struct {
Msg string
}

func (e *Bug) Error() string {
return e.Msg
}

// --

// LocalizableError is an error whose message is localizable.
func LocalizableError(format string, args ...any) error {
return &localizableError{format, args}
Expand Down

0 comments on commit 40de0fb

Please sign in to comment.