error.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* ssh-error.c -- Error reporting to Guile.
  2. *
  3. * Copyright (C) 2013, 2014, 2015, 2016, 2017 Artyom V. Poptsov <poptsov.artyom@gmail.com>
  4. *
  5. * This file is part of Guile-SSH.
  6. *
  7. * Guile-SSH is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Guile-SSH is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Guile-SSH. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <config.h>
  21. #include <libguile.h>
  22. #include <libssh/libssh.h>
  23. #include "error.h"
  24. #include "log.h"
  25. /* Report an error */
  26. void
  27. guile_ssh_error (const char *proc, const char *msg, SCM args, SCM rest)
  28. {
  29. scm_error (scm_from_locale_symbol (GUILE_SSH_ERROR), proc, msg, args, rest);
  30. }
  31. /* Report an error (shorter version). */
  32. void
  33. guile_ssh_error1 (const char *proc, const char *msg, SCM args)
  34. {
  35. _gssh_log_error (proc, msg, args);
  36. scm_error (scm_from_locale_symbol (GUILE_SSH_ERROR), proc, msg, args,
  37. SCM_BOOL_F);
  38. }
  39. /* Report a session error. */
  40. void
  41. guile_ssh_session_error1 (const char *proc, ssh_session session, SCM args)
  42. {
  43. guile_ssh_error1 (proc, ssh_get_error (session), args);
  44. }
  45. /* ssh-error.c ends here */