From 347a19ae9629ad06ab597a176672c9098c9af64a Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 19 Apr 2017 19:21:11 -0700 Subject: Add common routines for command-line libwiretap error reporting. These are similar to the routines added to ui/alert_box.c for dialog-box libwiretap error reporting. This centralizes the knowledge about what to say for various libwiretap errors, removing some duplicate code, and giving more details in some programs. Change-Id: I737405c4edaa0e6c27840f78a8c587a8b3ee120b Reviewed-on: https://code.wireshark.org/review/21234 Reviewed-by: Guy Harris --- rawshark.c | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'rawshark.c') diff --git a/rawshark.c b/rawshark.c index 0476223095..bcb2f8ca5d 100644 --- a/rawshark.c +++ b/rawshark.c @@ -82,6 +82,7 @@ #endif #include "ui/util.h" #include "ui/dissect_opts.h" +#include "ui/failure_message.h" #include "register.h" #include "conditions.h" #include "capture_stop_conditions.h" @@ -983,39 +984,7 @@ load_cap_file(capture_file *cf) g_free(pd); if (err != 0) { /* Print a message noting that the read failed somewhere along the line. */ - switch (err) { - - case WTAP_ERR_UNSUPPORTED: - cmdarg_err("The file \"%s\" contains record data that Rawshark doesn't support.\n(%s)", - cf->filename, - err_info != NULL ? err_info : "no information supplied"); - g_free(err_info); - break; - - case WTAP_ERR_SHORT_READ: - cmdarg_err("The file \"%s\" appears to have been cut short in the middle of a packet.", - cf->filename); - break; - - case WTAP_ERR_BAD_FILE: - cmdarg_err("The file \"%s\" appears to be damaged or corrupt.\n(%s)", - cf->filename, - err_info != NULL ? err_info : "no information supplied"); - g_free(err_info); - break; - - case WTAP_ERR_DECOMPRESS: - cmdarg_err("The compressed file \"%s\" appears to be damaged or corrupt.\n(%s)", - cf->filename, - err_info != NULL ? err_info : "no information supplied"); - g_free(err_info); - break; - - default: - cmdarg_err("An error occurred while reading the file \"%s\": %s.", - cf->filename, wtap_strerror(err)); - break; - } + cfile_read_failure_message("Rawshark", cf->filename, err, err_info); return FALSE; } -- cgit v1.2.3