Return error instead of crash if compile shader failed on D3D12

Bug: dawn:347
Change-Id: Id5cc8c9c7c3acf5daa6f17fd3235b584dd52d522
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18720
Commit-Queue: Hao Li <hao.x.li@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp
index 830860b..28df6de 100644
--- a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp
+++ b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp
@@ -15,6 +15,7 @@
 #include "dawn_native/d3d12/RenderPipelineD3D12.h"
 
 #include "common/Assert.h"
+#include "common/Log.h"
 #include "dawn_native/d3d12/D3D12Error.h"
 #include "dawn_native/d3d12/DeviceD3D12.h"
 #include "dawn_native/d3d12/PipelineLayoutD3D12.h"
@@ -341,11 +342,14 @@
             DAWN_TRY_ASSIGN(hlslSource, module->GetHLSLSource(ToBackend(GetLayout())));
 
             const PlatformFunctions* functions = device->GetFunctions();
-            if (FAILED(functions->d3dCompile(hlslSource.c_str(), hlslSource.length(), nullptr,
-                                             nullptr, nullptr, entryPoint, compileTarget,
-                                             compileFlags, 0, &compiledShader[stage], &errors))) {
-                printf("%s\n", reinterpret_cast<char*>(errors->GetBufferPointer()));
-                ASSERT(false);
+            MaybeError error = CheckHRESULT(
+                functions->d3dCompile(hlslSource.c_str(), hlslSource.length(), nullptr, nullptr,
+                                      nullptr, entryPoint, compileTarget, compileFlags, 0,
+                                      &compiledShader[stage], &errors),
+                "D3DCompile");
+            if (error.IsError()) {
+                dawn::WarningLog() << reinterpret_cast<char*>(errors->GetBufferPointer());
+                DAWN_TRY(std::move(error));
             }
 
             if (shader != nullptr) {