[dawn][node] Hook up GPUInternalError reporting

Change-Id: Ibe55e7088188e5009fbba378a7569febb2f794bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/169780
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/node/binding/GPUDevice.cpp b/src/dawn/node/binding/GPUDevice.cpp
index 91d69e1..463353e 100644
--- a/src/dawn/node/binding/GPUDevice.cpp
+++ b/src/dawn/node/binding/GPUDevice.cpp
@@ -134,6 +134,16 @@
     std::string message_;
 };
 
+class InternalError : public interop::GPUInternalError {
+  public:
+    explicit InternalError(std::string message) : message_(std::move(message)) {}
+
+    std::string getMessage(Napi::Env) override { return message_; };
+
+  private:
+    std::string message_;
+};
+
 }  // namespace
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -576,12 +586,18 @@
                     c->promise.Resolve(err);
                     break;
                 }
+                case WGPUErrorType::WGPUErrorType_Internal: {
+                    interop::Interface<interop::GPUError> err{
+                        interop::GPUInternalError::Create<InternalError>(env, message)};
+                    c->promise.Resolve(err);
+                    break;
+                }
                 case WGPUErrorType::WGPUErrorType_Unknown:
                 case WGPUErrorType::WGPUErrorType_DeviceLost:
                     c->promise.Reject(Errors::OperationError(env, message));
                     break;
                 default:
-                    c->promise.Reject("unhandled error type");
+                    c->promise.Reject("unhandled error type (" + std::to_string(type) + ")");
                     break;
             }
         },