Repository: dbt-labs/dbt-core

Issue:
Windows path issues... again
### Describe the bug
See this stack trace:
```
[Errno 2] No such file or directory: 'target\\compiled\\dbt_project\\models\\amp\\04_raw\\source_performance_media_imports_fivetran_netsuite_mapping.yml\\schema_test\\source_not_null_performance-media-imports_fivetran_netsuite_mapping_companies_mapping_netsuite_company_id.sql'
2020-06-30 07:52:45.975033 (Thread-4): 
Traceback (most recent call last):
  File "c:\users\dbt_user\anaconda3\envs\dbt_windows\lib\site-packages\dbt\node_runners.py", line 228, in safe_run
    result = self.compile_and_execute(manifest, ctx)
  File "c:\users\dbt_user\anaconda3\envs\dbt_windows\lib\site-packages\dbt\node_runners.py", line 165, in compile_and_execute
    ctx.node = self.compile(manifest)
  File "c:\users\dbt_user\anaconda3\envs\dbt_windows\lib\site-packages\dbt\node_runners.py", line 340, in compile
    return compile_node(self.adapter, self.config, self.node, manifest, {})
  File "c:\users\dbt_user\anaconda3\envs\dbt_windows\lib\site-packages\dbt\compilation.py", line 264, in compile_node
    node.injected_sql
  File "c:\users\dbt_user\anaconda3\envs\dbt_windows\lib\site-packages\dbt\contracts\graph\parsed.py", line 172, in write_node
    write_file(full_path, payload)
  File "c:\users\dbt_user\anaconda3\envs\dbt_windows\lib\site-packages\dbt\clients\system.py", line 136, in write_file
    with open(path, 'w', encoding='utf-8') as f:
```

### Steps To Reproduce
Must have something to do with the Windows/python version at play?? TBD, working on getting more info.

### Expected behavior
dbt should log a debug log line for the exception and move on without error


**The output of `dbt --version`:**
```
0.17.0-rc2
```

**The operating system you're using:** Windows (version TBD)

**The output of `python --version`:** TBD


Discussion:
😡 :rage1: :rage2: :rage3: :rage4: there are not enough rage emojis for how I feel about this

Resolving patch:
diff --git a/core/dbt/clients/system.py b/core/dbt/clients/system.py
--- a/core/dbt/clients/system.py
+++ b/core/dbt/clients/system.py
@@ -135,11 +135,14 @@ def write_file(path: str, contents: str = '') -> bool:
         make_directory(os.path.dirname(path))
         with open(path, 'w', encoding='utf-8') as f:
             f.write(str(contents))
-    except FileNotFoundError as exc:
-        if (
-            os.name == 'nt' and
-            len(path) >= 260
-        ):
+    except Exception as exc:
+        # note that you can't just catch FileNotFound, because sometimes
+        # windows apparently raises something else.
+        # It's also not sufficient to look at the path length, because
+        # sometimes windows fails to write paths that are less than the length
+        # limit. So on windows, suppress all errors that happen from writing
+        # to disk.
+        if os.name == 'nt':
             # sometimes we get a winerror of 3 which means the path was
             # definitely too long, but other times we don't and it means the
             # path was just probably too long. This is probably based on the
@@ -151,8 +154,8 @@ def write_file(path: str, contents: str = '') -> bool:
             # all our hard work and the path was still too long. Log and
             # continue.
             logger.debug(
-                f'Could not write to path {path}: {reason} '
-                f'({len(path)} characters)'
+                f'Could not write to path {path}({len(path)} characters): '
+                f'{reason}\nexception: {exc}'
             )
         else:
             raise


Test patch: