Skip to content

Commit

Permalink
log.Fatal([f])? -> log.Panic$1
Browse files Browse the repository at this point in the history
  • Loading branch information
limitedeternity committed Apr 25, 2024
1 parent 16f5cff commit ec35b70
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (s *SolverBase[I, S]) InjectKnapsack(knapsack any) {
case nil:
s.Knapsack = nil
default:
log.Fatalf("Unsupported knapsack type: %T, expected: %T", knapsack, s.Knapsack)
log.Panicf("Unsupported knapsack type: %T, expected: %T", knapsack, s.Knapsack)
}
}

Expand All @@ -78,20 +78,20 @@ func (k *Knapsack[I, S]) WithCapacity(limit int) *Knapsack[I, S] {

func (k *Knapsack[I, S]) Pack(items []I) Solution {
if k.Limit <= 0 {
log.Fatal("Knapsack capacity must be greater than zero")
log.Panic("Knapsack capacity must be greater than zero")
}

k.Items = items

if reflect.TypeFor[S]().Kind() != reflect.Ptr {
log.Fatal("Solver type parameter must be a pointer")
log.Panic("Solver type parameter must be a pointer")
}

solver := reflect.New(reflect.TypeFor[S]().Elem()).Interface().(Solver)
base := solver.GetBase()

if reflect.TypeOf(base).Kind() != reflect.Ptr {
log.Fatal("GetBase() must return a pointer")
log.Panic("GetBase() must return a pointer")
}

base.InjectKnapsack(k)
Expand Down

0 comments on commit ec35b70

Please sign in to comment.