| 1 | /* |
| 2 | Copyright(C) 2014 Brazil |
| 3 | Copyright(C) 2020-2023 Sutou Kouhei <[email protected]> |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include "../grn_ctx_impl.h" |
| 21 | |
| 22 | #ifdef GRN_WITH_MRUBY |
| 23 | # include <mruby.h> |
| 24 | |
| 25 | # include "../grn_mrb.h" |
| 26 | # include "mrb_error.h" |
| 27 | |
| 28 | void |
| 29 | grn_mrb_error_init(grn_ctx *ctx) |
| 30 | { |
| 31 | grn_mrb_data *data = &(ctx->impl->mrb); |
| 32 | mrb_state *mrb = data->state; |
| 33 | struct RClass *module = data->module; |
| 34 | struct RClass *error_class; |
| 35 | struct RClass *groonga_error_class; |
| 36 | |
| 37 | error_class = |
| 38 | mrb_define_class_under(mrb, module, "Error", mrb->eStandardError_class); |
| 39 | groonga_error_class = |
| 40 | mrb_define_class_under(mrb, module, "GroongaError", error_class); |
| 41 | |
| 42 | mrb_define_class_under(mrb, module, "EndOfData", groonga_error_class); |
| 43 | mrb_define_class_under(mrb, module, "UnknownError", groonga_error_class); |
| 44 | mrb_define_class_under(mrb, |
| 45 | module, |
| 46 | "OperationNotPermitted", |
| 47 | groonga_error_class); |
| 48 | mrb_define_class_under(mrb, |
| 49 | module, |
| 50 | "NoSuchFileOrDirectory", |
| 51 | groonga_error_class); |
| 52 | mrb_define_class_under(mrb, module, "NoSuchProcess", groonga_error_class); |
| 53 | mrb_define_class_under(mrb, |
| 54 | module, |
| 55 | "InterruptedFunctionCall", |
| 56 | groonga_error_class); |
| 57 | mrb_define_class_under(mrb, module, "InputOutputError", groonga_error_class); |
| 58 | mrb_define_class_under(mrb, |
| 59 | module, |
| 60 | "NoSuchDeviceOrAddress", |
| 61 | groonga_error_class); |
| 62 | mrb_define_class_under(mrb, module, "ArgListTooLong", groonga_error_class); |
| 63 | mrb_define_class_under(mrb, module, "ExecFormatError", groonga_error_class); |
| 64 | mrb_define_class_under(mrb, module, "BadFileDescriptor", groonga_error_class); |
| 65 | mrb_define_class_under(mrb, module, "NoChildProcesses", groonga_error_class); |
| 66 | mrb_define_class_under(mrb, |
| 67 | module, |
| 68 | "ResourceTemporarilyUnavailable", |
| 69 | groonga_error_class); |
| 70 | mrb_define_class_under(mrb, module, "NotEnoughSpace", groonga_error_class); |
| 71 | mrb_define_class_under(mrb, module, "PermissionDenied", groonga_error_class); |
| 72 | mrb_define_class_under(mrb, module, "BadAddress", groonga_error_class); |
| 73 | mrb_define_class_under(mrb, module, "ResourceBusy", groonga_error_class); |
| 74 | mrb_define_class_under(mrb, module, "FileExists", groonga_error_class); |
| 75 | mrb_define_class_under(mrb, module, "ImproperLink", groonga_error_class); |
| 76 | mrb_define_class_under(mrb, module, "NoSuchDevice", groonga_error_class); |
| 77 | mrb_define_class_under(mrb, module, "NotDirectory", groonga_error_class); |
| 78 | mrb_define_class_under(mrb, module, "IsDirectory", groonga_error_class); |
| 79 | mrb_define_class_under(mrb, module, "InvalidArgument", groonga_error_class); |
| 80 | mrb_define_class_under(mrb, |
| 81 | module, |
| 82 | "TooManyOpenFilesInSystem", |
| 83 | groonga_error_class); |
| 84 | mrb_define_class_under(mrb, module, "TooManyOpenFiles", groonga_error_class); |
| 85 | mrb_define_class_under(mrb, |
| 86 | module, |
| 87 | "InappropriateIOControlOperation", |
| 88 | groonga_error_class); |
| 89 | mrb_define_class_under(mrb, module, "FileTooLarge", groonga_error_class); |
| 90 | mrb_define_class_under(mrb, |
| 91 | module, |
| 92 | "NoSpaceLeftOnDevice", |
| 93 | groonga_error_class); |
| 94 | mrb_define_class_under(mrb, module, "InvalidSeek", groonga_error_class); |
| 95 | mrb_define_class_under(mrb, |
| 96 | module, |
| 97 | "ReadOnlyFileSystem", |
| 98 | groonga_error_class); |
| 99 | mrb_define_class_under(mrb, module, "TooManyLinks", groonga_error_class); |
| 100 | mrb_define_class_under(mrb, module, "BrokenPipe", groonga_error_class); |
| 101 | mrb_define_class_under(mrb, module, "DomainError", groonga_error_class); |
| 102 | mrb_define_class_under(mrb, module, "ResultTooLarge", groonga_error_class); |
| 103 | mrb_define_class_under(mrb, |
| 104 | module, |
| 105 | "ResourceDeadlockAvoided", |
| 106 | groonga_error_class); |
| 107 | mrb_define_class_under(mrb, module, "NoMemoryAvailable", groonga_error_class); |
| 108 | mrb_define_class_under(mrb, module, "FilenameTooLong", groonga_error_class); |
| 109 | mrb_define_class_under(mrb, module, "NoLocksAvailable", groonga_error_class); |
| 110 | mrb_define_class_under(mrb, |
| 111 | module, |
| 112 | "FunctionNotImplemented", |
| 113 | groonga_error_class); |
| 114 | mrb_define_class_under(mrb, module, "DirectoryNotEmpty", groonga_error_class); |
| 115 | mrb_define_class_under(mrb, |
| 116 | module, |
| 117 | "IllegalByteSequence", |
| 118 | groonga_error_class); |
| 119 | mrb_define_class_under(mrb, |
| 120 | module, |
| 121 | "SocketNotInitialized", |
| 122 | groonga_error_class); |
| 123 | mrb_define_class_under(mrb, |
| 124 | module, |
| 125 | "OperationWouldBlock", |
| 126 | groonga_error_class); |
| 127 | mrb_define_class_under(mrb, |
| 128 | module, |
| 129 | "AddressIsNotAvailable", |
| 130 | groonga_error_class); |
| 131 | mrb_define_class_under(mrb, module, "NetworkIsDown", groonga_error_class); |
| 132 | mrb_define_class_under(mrb, module, "NoBuffer", groonga_error_class); |
| 133 | mrb_define_class_under(mrb, |
| 134 | module, |
| 135 | "SocketIsAlreadyConnected", |
| 136 | groonga_error_class); |
| 137 | mrb_define_class_under(mrb, |
| 138 | module, |
| 139 | "SocketIsNotConnected", |
| 140 | groonga_error_class); |
| 141 | mrb_define_class_under(mrb, |
| 142 | module, |
| 143 | "SocketIsAlreadyShutdowned", |
| 144 | groonga_error_class); |
| 145 | mrb_define_class_under(mrb, module, "OperationTimeout", groonga_error_class); |
| 146 | mrb_define_class_under(mrb, module, "ConnectionRefused", groonga_error_class); |
| 147 | mrb_define_class_under(mrb, module, "RangeError", groonga_error_class); |
| 148 | mrb_define_class_under(mrb, module, "TokenizerError", groonga_error_class); |
| 149 | mrb_define_class_under(mrb, module, "FileCorrupt", groonga_error_class); |
| 150 | mrb_define_class_under(mrb, module, "InvalidFormat", groonga_error_class); |
| 151 | mrb_define_class_under(mrb, module, "ObjectCorrupt", groonga_error_class); |
| 152 | mrb_define_class_under(mrb, |
| 153 | module, |
| 154 | "TooManySymbolicLinks", |
| 155 | groonga_error_class); |
| 156 | mrb_define_class_under(mrb, module, "NotSocket", groonga_error_class); |
| 157 | mrb_define_class_under(mrb, |
| 158 | module, |
| 159 | "OperationNotSupported", |
| 160 | groonga_error_class); |
| 161 | mrb_define_class_under(mrb, module, "AddressIsInUse", groonga_error_class); |
| 162 | mrb_define_class_under(mrb, module, "ZlibError", groonga_error_class); |
| 163 | mrb_define_class_under(mrb, module, "LZ4Error", groonga_error_class); |
| 164 | mrb_define_class_under(mrb, module, "StackOverFlow", groonga_error_class); |
| 165 | mrb_define_class_under(mrb, module, "SyntaxError", groonga_error_class); |
| 166 | mrb_define_class_under(mrb, module, "RetryMax", groonga_error_class); |
| 167 | mrb_define_class_under(mrb, |
| 168 | module, |
| 169 | "IncompatibleFileFormat", |
| 170 | groonga_error_class); |
| 171 | mrb_define_class_under(mrb, module, "UpdateNotAllowed", groonga_error_class); |
| 172 | mrb_define_class_under(mrb, module, "TooSmallOffset", groonga_error_class); |
| 173 | mrb_define_class_under(mrb, module, "TooLargeOffset", groonga_error_class); |
| 174 | mrb_define_class_under(mrb, module, "TooSmallLimit", groonga_error_class); |
| 175 | mrb_define_class_under(mrb, module, "CASError", groonga_error_class); |
| 176 | mrb_define_class_under(mrb, |
| 177 | module, |
| 178 | "UnsupportedCommandVersion", |
| 179 | groonga_error_class); |
| 180 | mrb_define_class_under(mrb, module, "NormalizerError", groonga_error_class); |
| 181 | mrb_define_class_under(mrb, module, "TokenFilterError", groonga_error_class); |
| 182 | mrb_define_class_under(mrb, module, "CommandError", groonga_error_class); |
| 183 | mrb_define_class_under(mrb, module, "PluginError", groonga_error_class); |
| 184 | mrb_define_class_under(mrb, module, "ScorerError", groonga_error_class); |
| 185 | mrb_define_class_under(mrb, module, "Cancel", groonga_error_class); |
| 186 | mrb_define_class_under(mrb, |
| 187 | module, |
| 188 | "WindowFunctionError", |
| 189 | groonga_error_class); |
| 190 | mrb_define_class_under(mrb, module, "ZstdError", groonga_error_class); |
| 191 | mrb_define_class_under(mrb, module, "ConnectionReset", groonga_error_class); |
| 192 | mrb_define_class_under(mrb, module, "BloscError", groonga_error_class); |
| 193 | } |
| 194 | #endif |