updated cast panic to echo arg type

This commit is contained in:
alexchao26
2020-12-26 15:46:17 -05:00
parent aed39a0ede
commit 170d43a7ec
+6 -3
View File
@@ -3,7 +3,10 @@ package cast
// Suite of casting functions to speed up solutions // Suite of casting functions to speed up solutions
// This is NOT idiomatic Go... but AOC isn't about that... // This is NOT idiomatic Go... but AOC isn't about that...
import "strconv" import (
"fmt"
"strconv"
)
// ToInt will case a given arg into an int type. // ToInt will case a given arg into an int type.
// Supported types are: // Supported types are:
@@ -18,7 +21,7 @@ func ToInt(arg interface{}) int {
panic("error converting string to int " + err.Error()) panic("error converting string to int " + err.Error())
} }
default: default:
panic("unhandled type for int casting") panic(fmt.Sprintf("unhandled type for int casting %T", arg))
} }
return val return val
} }
@@ -39,7 +42,7 @@ func ToString(arg interface{}) string {
case rune: case rune:
str = string(arg.(rune)) str = string(arg.(rune))
default: default:
panic("unhandled type for string casting") panic(fmt.Sprintf("unhandled type for string casting %T", arg))
} }
return str return str
} }