EA-47394 (IVFAE diagnostic)

This commit is contained in:
Roman Shevchenko
2013-07-03 19:38:50 +02:00
parent 44e6458fce
commit 6f9726deb5
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,25 @@ package com.intellij.openapi.vfs;
*/
public class InvalidVirtualFileAccessException extends RuntimeException {
public InvalidVirtualFileAccessException(final VirtualFile file) {
super("Accessing invalid virtual file: " + file.getUrl());
super(composeMessage(file));
}
private static String composeMessage(VirtualFile file) {
String url = file.getUrl();
String message = "Accessing invalid virtual file: " + url;
try {
VirtualFile found = VirtualFileManager.getInstance().findFileByUrl(url);
message += "; original:" + hashCode(file) + "; found:" + hashCode(found);
}
catch (Throwable t) {
message += "; lookup failed: " + t.getMessage();
}
return message;
}
private static int hashCode(Object o) {
return o != null ? o.hashCode() : 0;
}
}