Allow error message callback cancellation regardless of socket state.
[folly.git] / folly / io / async / AsyncSocketException.h
index 3113197c4b207b94208c1c3500ea958883bb81fb..2033be05441d59bfa540dc0744a20af8c935f097 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
 
 #pragma once
 
+#include <stdexcept>
+
 #include <folly/Format.h>
 #include <folly/io/async/DelayedDestruction.h>
 
@@ -23,21 +25,22 @@ namespace folly {
 
 class AsyncSocketException : public std::runtime_error {
  public:
-  enum AsyncSocketExceptionType
-  { UNKNOWN = 0
-  , NOT_OPEN = 1
-  , ALREADY_OPEN = 2
-  , TIMED_OUT = 3
-  , END_OF_FILE = 4
-  , INTERRUPTED = 5
-  , BAD_ARGS = 6
-  , CORRUPTED_DATA = 7
-  , INTERNAL_ERROR = 8
-  , NOT_SUPPORTED = 9
-  , INVALID_STATE = 10
-  , SSL_ERROR = 12
-  , COULD_NOT_BIND = 13
-  , SASL_HANDSHAKE_TIMEOUT = 14
+  enum AsyncSocketExceptionType {
+    UNKNOWN = 0,
+    NOT_OPEN = 1,
+    ALREADY_OPEN = 2,
+    TIMED_OUT = 3,
+    END_OF_FILE = 4,
+    INTERRUPTED = 5,
+    BAD_ARGS = 6,
+    CORRUPTED_DATA = 7,
+    INTERNAL_ERROR = 8,
+    NOT_SUPPORTED = 9,
+    INVALID_STATE = 10,
+    SSL_ERROR = 12,
+    COULD_NOT_BIND = 13,
+    SASL_HANDSHAKE_TIMEOUT = 14,
+    NETWORK_ERROR = 15
   };
 
   AsyncSocketException(AsyncSocketExceptionType type,
@@ -95,6 +98,8 @@ class AsyncSocketException : public std::runtime_error {
         return "Could not bind";
       case SASL_HANDSHAKE_TIMEOUT:
         return "SASL handshake timeout";
+      case NETWORK_ERROR:
+        return "Network error";
       default:
         return "(Invalid exception type)";
     }