error.cc
来自「一个mips虚拟机非常好代码,使用C++来编写的,希望大家多学学,」· CC 代码 · 共 72 行
CC
72 行
#include <errno.h>#include <stdarg.h>#include <string.h>#include "error.hh"#include "sulima.hh"// Construct an error message from a printf-like template.Error::Error(const char *m, ...){ va_list ap; va_start(ap, m); if (vecho(msg, sizeof(msg), m, ap) >= sizeof(msg)) strcpy(msg + sizeof(msg) - 5, "..."); va_end(ap);}// An empty virtual destructor.Error::~Error(){ // nothing to do.}// Access to the message string.const char *Error::what() const{ return msg;}// Return a "cascaded exception" message.const char *Error::cascaded(){ return "Cascaded exception detected.";}// Print an out-of-memory message. This is worth special-casing.const char *OutOfMemory::what() const{ return "Out of memory.";}// A generic error message stored in `errno'.SysError::SysError() : ec(errno){ // done.}const char *SysError::what() const{ return strerror(ec);}// A file-related SysError.FileError::FileError(const char *name) : Error("%s: %s", name, strerror(errno)){ // done.}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?