Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bettererrors #163

Merged
merged 2 commits into from
Jul 21, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -456,15 +456,15 @@ record = null;
length = workItem.Reader.ReadInt32(); length = workItem.Reader.ReadInt32();
if (length <= 0) if (length <= 0)
{ {
throw new ArgumentException( throw new InvalidReadException(
string.Format("Log record at actual pos {0} has non-positive length: {1}. " string.Format("Log record at actual pos {0} has non-positive length: {1}. "
+ "Something is seriously wrong in chunk {2}.", actualPosition, length, Chunk)); + " in chunk.", actualPosition, length, Chunk));
} }
if (length > TFConsts.MaxLogRecordSize) if (length > TFConsts.MaxLogRecordSize)
{ {
throw new ArgumentException( throw new InvalidReadException(
string.Format("Log record at actual pos {0} has too large length: {1} bytes, " string.Format("Log record at actual pos {0} has too large length: {1} bytes, "
+ "while limit is {2} bytes. Something is seriously wrong in chunk {3}.", + "while limit is {2} bytes. In chunk {3}.",
actualPosition, length, TFConsts.MaxLogRecordSize, Chunk)); actualPosition, length, TFConsts.MaxLogRecordSize, Chunk));
} }
if (actualPosition + length + 2 * sizeof(int) > Chunk.PhysicalDataSize) if (actualPosition + length + 2 * sizeof(int) > Chunk.PhysicalDataSize)
Expand Down Expand Up @@ -504,16 +504,16 @@ record = null;
length = workItem.Reader.ReadInt32(); length = workItem.Reader.ReadInt32();
if (length <= 0) if (length <= 0)
{ {
throw new ArgumentException( throw new InvalidReadException(
string.Format("Log record that ends at actual pos {0} has non-positive length: {1}. " string.Format("Log record that ends at actual pos {0} has non-positive length: {1}. "
+ "Something is seriously wrong in chunk {2}.", + "In chunk {2}.",
actualPosition, length, Chunk)); actualPosition, length, Chunk));
} }
if (length > TFConsts.MaxLogRecordSize) if (length > TFConsts.MaxLogRecordSize)
{ {
throw new ArgumentException( throw new ArgumentException(
string.Format("Log record that ends at actual pos {0} has too large length: {1} bytes, " string.Format("Log record that ends at actual pos {0} has too large length: {1} bytes, "
+ "while limit is {2} bytes. Something is seriously wrong in chunk {3}.", + "while limit is {2} bytes. In chunk {3}.",
actualPosition, length, TFConsts.MaxLogRecordSize, Chunk)); actualPosition, length, TFConsts.MaxLogRecordSize, Chunk));
} }
if (actualPosition < length + 2 * sizeof(int)) // no space for record + length prefix and suffix if (actualPosition < length + 2 * sizeof(int)) // no space for record + length prefix and suffix
Expand Down Expand Up @@ -541,4 +541,8 @@ record = LogRecord.ReadFrom(workItem.Reader);
} }
} }
} }

public class InvalidReadException : Exception {
public InvalidReadException(string message) : base(message) {}
}
} }