File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -243,9 +243,9 @@ Development tools:
243243
2442442022-09-09 v1.0.0
245245
246- V1 released with the following depreciated identifiers removed:
246+ V1 release has the following depreciated identifiers removed:
247247
248- - The ` Server ` interface is removed, use ` ServerCloser ` instead.
248+ - The ` Server ` interface is removed. Use ` ServerCloser ` instead.
249249- Public global variable ` DebugOut ` is changed to private. Use ` SetDebugOut(w io.Writer) ` instead for thread safety.
250250- Type alias ` type ProtocalHandler = ProtocolHandler ` removed.
251251- Function redirect from ` GetRTUBidirectionSizeFromHeader ` to ` GetRTUBidirectionalSizeFromHeader ` removed.
Original file line number Diff line number Diff line change @@ -241,15 +241,20 @@ func (e ExceptionCode) Error() string {
241241 return fmt .Sprintf ("ExceptionCode:0x%02X" , byte (e ))
242242}
243243
244- // ToExceptionCode turns an error into an ExceptionCode (to send in PDU), best
244+ // ToExceptionCode turns an error into an ExceptionCode (to send in PDU). Best
245245// effort with EcServerDeviceFailure as fail back.
246+ //
247+ // - If the error is a ExceptionCode or warped ExceptionCode,
248+ // the original ExceptionCode is returned.
249+ // - IF the error is ErrFcNotSupported or warped ErrFcNotSupported,
250+ // EcIllegalFunction is returned.
251+ // - For all other cases, EcServerDeviceFailure is returned.
246252func ToExceptionCode (err error ) ExceptionCode {
247253 if err == nil {
248254 debugf ("ToExceptionCode: unexpected covert nil error to ExceptionCode" )
255+ return EcServerDeviceFailure
249256 }
250- var e ExceptionCode
251- ok := errors .As (err , & e )
252- if ok {
257+ if e := ExceptionCode (0 ); errors .As (err , & e ) {
253258 return e
254259 }
255260 if errors .Is (err , ErrFcNotSupported ) {
You can’t perform that action at this time.
0 commit comments