<commit_before>// Copyright 2009 The Go Authors.  All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package srv

import "code.google.com/p/go9p/p"

// Respond to the request with Rerror message
func (req *Req) RespondError(err interface{}) {
	e := err.(*p.Error)
	p.PackRerror(req.Rc, e.Error(), uint32(e.Errornum), req.Conn.Dotu)
	req.Respond()
}
<commit_msg>better handling of errors<commit_after>// Copyright 2009 The Go Authors.  All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package srv

import "fmt"
import "code.google.com/p/go9p/p"

// Respond to the request with Rerror message
func (req *Req) RespondError(err interface{}) {
	switch e := err.(type) {
	case *p.Error:
		p.PackRerror(req.Rc, e.Error(), uint32(e.Errornum), req.Conn.Dotu)
	case error:
		p.PackRerror(req.Rc, e.Error(), uint32(p.EIO), req.Conn.Dotu)
	default:
		p.PackRerror(req.Rc, fmt.Sprintf("%v", e), uint32(p.EIO), req.Conn.Dotu)
	}

	req.Respond()
}

{'fraction_non_alphanumeric': 0.14101382488479264, 'fraction_numerical': 0.016589861751152075, 'mean_word_length': 3.8266666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '716707', 'n_tokens_mistral': 413, 'n_tokens_neox': 389, 'n_words': 122}