hadoop_err.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef HADOOP_CORE_COMMON_HADOOP_ERR
  19. #define HADOOP_CORE_COMMON_HADOOP_ERR
  20. #include <uv.h> /* for uv_loop_t */
  21. /**
  22. * A Hadoop error. This is the libhadoop-core version of an IOException.
  23. */
  24. struct hadoop_err;
  25. /**
  26. * Allocate a new local error.
  27. *
  28. * @param code Error code.
  29. * @param fmt printf-style format.
  30. * @param ... printf-style arguments.
  31. *
  32. * @return A new error message. This will never be NULL.
  33. */
  34. struct hadoop_err *hadoop_lerr_alloc(int code, const char *fmt, ...)
  35. __attribute__((format(printf, 2, 3)));
  36. /**
  37. * Allocate a new error object based on a libuv error.
  38. *
  39. * @param loop The libuv loop to check.
  40. * @param fmt printf-style format.
  41. * @param ... printf-style arguments.
  42. *
  43. * @return A new error message. This will never be NULL.
  44. */
  45. struct hadoop_err *hadoop_uverr_alloc(int code, const char *fmt, ...)
  46. __attribute__((format(printf, 2, 3)));
  47. /**
  48. * Given a hadoop error, get the error code.
  49. *
  50. * @param err The hadoop error.
  51. *
  52. * @return The error code.
  53. */
  54. int hadoop_err_code(const struct hadoop_err *err);
  55. /**
  56. * Given a hadoop error, get the error message.
  57. *
  58. * @param err The hadoop error.
  59. *
  60. * @return The error message. Valid until the hadoop_err
  61. * object is freed.
  62. */
  63. const char *hadoop_err_msg(const struct hadoop_err *err);
  64. /**
  65. * Free a hadoop error.
  66. *
  67. * @param err The hadoop error.
  68. */
  69. void hadoop_err_free(struct hadoop_err *err);
  70. #endif
  71. // vim: ts=4:sw=4:tw=79:et