From 2b80057ac9aed81cfec07a548f455f14e7b05d4f Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 13 Dec 2015 10:38:21 +0100 Subject: [PATCH] Minimal error handling refactor --- lib/upnp/upnp.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/upnp/upnp.go b/lib/upnp/upnp.go index c5456281..b44baf6f 100644 --- a/lib/upnp/upnp.go +++ b/lib/upnp/upnp.go @@ -531,9 +531,8 @@ func (s *IGDService) AddPortMapping(localIPAddress string, protocol Protocol, ex if err != nil && timeout > 0 { // Try to repair error code 725 - OnlyPermanentLeasesSupported envelope := &soapErrorResponse{} - err2 := xml.Unmarshal(response, envelope) - if err2 != nil { - return err2 + if unmarshalErr := xml.Unmarshal(response, envelope); unmarshalErr != nil { + return unmarshalErr } if envelope.ErrorCode == 725 { return s.AddPortMapping(localIPAddress, protocol, externalPort, internalPort, description, 0)