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:
243
243
244
244
2022-09-09 v1.0.0
245
245
246
- V1 released with the following depreciated identifiers removed:
246
+ V1 release has the following depreciated identifiers removed:
247
247
248
- - The ` Server ` interface is removed, use ` ServerCloser ` instead.
248
+ - The ` Server ` interface is removed. Use ` ServerCloser ` instead.
249
249
- Public global variable ` DebugOut ` is changed to private. Use ` SetDebugOut(w io.Writer) ` instead for thread safety.
250
250
- Type alias ` type ProtocalHandler = ProtocolHandler ` removed.
251
251
- 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 {
241
241
return fmt .Sprintf ("ExceptionCode:0x%02X" , byte (e ))
242
242
}
243
243
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
245
245
// 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.
246
252
func ToExceptionCode (err error ) ExceptionCode {
247
253
if err == nil {
248
254
debugf ("ToExceptionCode: unexpected covert nil error to ExceptionCode" )
255
+ return EcServerDeviceFailure
249
256
}
250
- var e ExceptionCode
251
- ok := errors .As (err , & e )
252
- if ok {
257
+ if e := ExceptionCode (0 ); errors .As (err , & e ) {
253
258
return e
254
259
}
255
260
if errors .Is (err , ErrFcNotSupported ) {
You can’t perform that action at this time.
0 commit comments