// You can edit this code!
// Click here and start typing.
package main

import (
	"fmt"
	"log"
)

type matcher func(rune) bool

func main() {
	m := func(r rune) bool {
		defer panic("hahaha")
		if r == 'g' || r == 'o' {
			return true
		}
		return false
	}
	s, err := sanitize(m, "go is awesome")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(s)
}

func sanitize(m matcher, s string) (val string, err error) {
	defer func() {
		if e := recover(); e != nil {
			err = fmt.Errorf("invalid matcher. panic occurred: %v", e)
		}
	}()

	for _, c := range s {
		if m(c) {
			val = val + "*"
			continue
		}
		val = val + string(c)
	}
	return
}
