LLVM 18.0.0git
BinaryStreamError.cpp
Go to the documentation of this file.
1//===- BinaryStreamError.cpp - Error extensions for streams -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11
12using namespace llvm;
13
15
17 : BinaryStreamError(C, "") {}
18
21
23 : Code(C) {
24 ErrMsg = "Stream Error: ";
25 switch (C) {
27 ErrMsg += "An unspecified error has occurred.";
28 break;
30 ErrMsg += "The stream is too short to perform the requested operation.";
31 break;
33 ErrMsg += "The buffer size is not a multiple of the array element size.";
34 break;
36 ErrMsg += "The specified offset is invalid for the current stream.";
37 break;
39 ErrMsg += "An I/O error occurred on the file system.";
40 break;
41 }
42
43 if (!Context.empty()) {
44 ErrMsg += " ";
45 ErrMsg += Context;
46 }
47}
48
49void BinaryStreamError::log(raw_ostream &OS) const { OS << ErrMsg; }
50
52
55}
LLVMContext & Context
raw_pwrite_stream & OS
Base class for errors originating when parsing raw PDB files.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
BinaryStreamError(stream_error_code C)
void log(raw_ostream &OS) const override
Print an error message to an output stream.
StringRef getErrorMessage() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:90