1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Better diagnostics of database corruption.

This commit is contained in:
Sergey Prigogin 2012-08-30 16:46:38 -07:00
parent 8478c43043
commit f351138c31
3 changed files with 18 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2007 QNX Software Systems and others.
* Copyright (c) 2005, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -26,4 +26,8 @@ public class DBStatus extends Status {
public DBStatus(IOException exception) {
super(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, "IOException", exception); //$NON-NLS-1$
}
public DBStatus(String msg) {
super(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, "Error", null); //$NON-NLS-1$
}
}

View file

@ -29,6 +29,8 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import com.ibm.icu.text.MessageFormat;
/**
* Database encapsulates access to a flat binary format file with a memory-manager-like API for
* obtaining and releasing areas of storage (memory).
@ -264,6 +266,9 @@ public class Database {
synchronized (fCache) {
assert fLocked;
final int index = (int) long_index;
if (index < 0 || index >= fChunks.length) {
databaseCorruptionDetected();
}
Chunk chunk= fChunks[index];
if (chunk == null) {
cacheMisses++;
@ -277,6 +282,12 @@ public class Database {
}
}
private void databaseCorruptionDetected() throws CoreException {
String msg = MessageFormat.format(Messages.getString("Database.CorruptedDatabase"), //$NON-NLS-1$
new Object[] { fLocation.getName() });
throw new CoreException(new DBStatus(msg));
}
/**
* Allocate a block out of the database.
*/

View file

@ -16,3 +16,4 @@ BTree.IntegrityErrorA=[{0} blanks inconsistent b={1} nb={2}]
BTree.IntegrityErrorB=[{0} wrong number of children with respect to key count]
BTree.IntegrityErrorC=[{0} key count out of range]
BTree.IntegrityErrorD=Leaf nodes at differing depths
Database.CorruptedDatabase=Corrupted database: {0}