ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/GoogleTron/Zlib/Error.hpp
Revision: 686
Committed: 2006-03-06T17:40:59-08:00 (19 years, 3 months ago) by douglas
File size: 892 byte(s)
Log Message:
dynamic_cast<Cool *>(stuff);

File Contents

# Content
1 // Error
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #ifndef _Zlib_Error_hpp_
8 #define _Zlib_Error_hpp_
9
10 #include <cxx/platform.hpp>
11
12 #ifdef MENES_PRAGMA_ONCE
13 #pragma once
14 #endif
15
16 #include <api/error.hpp>
17
18 #include <errno.h>
19 #include <zlib.h>
20
21 namespace Zlib
22 {
23
24 class Error : public api::Error
25 {
26 int code;
27 cse::String message;
28 public:
29 Error(gzFile file) : message(::gzerror(file, &code))
30 {
31 if (code == Z_ERRNO)
32 #if defined(API_HAS_POSIX)
33 throw api::Posix::Error();
34 #endif
35 }
36
37 virtual int GetNumber() const
38 {
39 return code;
40 }
41
42 virtual cse::String GetMessage() const
43 {
44 return _S<ios::String>() << "Zlib[#" << code << "] " << message;
45 }
46 };
47
48 _finline gzFile CheckError(gzFile status)
49 {
50 if (status == NULL)
51 throw Error(status);
52
53 return status;
54 }
55
56 _finline int CheckError(int status, gzFile file)
57 {
58 if (status != Z_OK)
59 throw Error(file);
60
61 return status;
62 }
63
64 }
65
66 #endif//_Zlib_Error_hpp_

Properties

Name Value
svn:eol-style native
svn:keywords Id