diff --git a/scserver.js b/scserver.js
index <HASH>..<HASH> 100644
--- a/scserver.js
+++ b/scserver.js
@@ -877,7 +877,10 @@ SCServer.prototype._passThroughHandshakeSCMiddleware = function (options, cb) {
           statusCode = 4008;
         }
         if (err) {
-          if (err === true) {
+          if (err.statusCode != null) {
+            statusCode = err.statusCode;
+          }
+          if (err === true || err.silent) {
             err = new SilentMiddlewareBlockedError('Action was silently blocked by ' + self.MIDDLEWARE_HANDSHAKE_SC + ' middleware', self.MIDDLEWARE_HANDSHAKE_SC);
           } else if (self.middlewareEmitWarnings) {
             self.emit('warning', err);
Add support for custom disconnect status code in handshake middleware when using async function