📄 error.cc
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -