LLVM  6.0.0svn
BinaryStreamError.cpp
Go to the documentation of this file.
1 //===- BinaryStreamError.cpp - Error extensions for streams -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
12 
13 using namespace llvm;
14 
15 char BinaryStreamError::ID = 0;
16 
18  : BinaryStreamError(C, "") {}
19 
22 
24  : Code(C) {
25  ErrMsg = "Stream Error: ";
26  switch (C) {
28  ErrMsg += "An unspecified error has occurred.";
29  break;
31  ErrMsg += "The stream is too short to perform the requested operation.";
32  break;
34  ErrMsg += "The buffer size is not a multiple of the array element size.";
35  break;
37  ErrMsg += "The specified offset is invalid for the current stream.";
38  break;
40  ErrMsg += "An I/O error occurred on the file system.";
41  break;
42  }
43 
44  if (!Context.empty()) {
45  ErrMsg += " ";
46  ErrMsg += Context;
47  }
48 }
49 
50 void BinaryStreamError::log(raw_ostream &OS) const { OS << ErrMsg << "\n"; }
51 
53 
54 std::error_code BinaryStreamError::convertToErrorCode() const {
55  return inconvertibleErrorCode();
56 }
uint64_t CallInst * C
LLVMContext & Context
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
void log(raw_ostream &OS) const override
Print an error message to an output stream.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
Base class for errors originating when parsing raw PDB files.
BinaryStreamError(stream_error_code C)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
StringRef getErrorMessage() const
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:73