Looks like it should work...
The error is thrown at line 12, which is one of those (can't tell from your code):
var search = Extent(Buffer($feature, .01, "feet"))
var segment = Clip(line, search)["paths"][0]
Try these (separate or in combination):
var search = Extent(Buffer($feature, 0.1, "feet")) // bigger buffer
var clip_geometry = Clip(Geometry(line), search) // use Geometry(line)
// test if the clip was successfull and return null (or a specific failure value) if not
// this won't solve the underlying problem, but will stop the error
if(clip_geometry == null) {
return null // return -9999
}
var segment = clip_geometry.paths[0] // .paths instead of ["paths"]
Also:
// Instead of doing the IsEmpty check before returning, do it at the start of the script, so you can return early.
if(!IsEmpty($feature.ROTATION)) {
return $feature.ROTATION
}
var lineClass = ...
// ...
return Angle(segment[0], segment[-1])
Have a great day!
Johannes