aboutsummaryrefslogtreecommitdiffstats
path: root/alert_box.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-11-19 20:18:01 +0000
committerGuy Harris <guy@alum.mit.edu>2011-11-19 20:18:01 +0000
commit2929c93ea276766076aed8bf617befba65d32eb4 (patch)
tree23f6e64eaa570e79fd24e3dd413e77eed56f9737 /alert_box.c
parent4b2aa811e14412e3731714e4e54c344e967173c1 (diff)
When reporting "sorry, *this* packet can't be written to a file of that
type" when writing out a capture file (i.e., writing a per-packet-encapsulation capture to a file type that supports it but doesn't support one of the packet's encapsulations), report the packet number and, when doing this in a merge operation, report the file from which it came. When reporting "sorry, that file can't be written to a file of that type, period", show the file type rather than the input file link-layer type that causes the problem. (We could show both. We could be *really* ambitious and iterate through all possible file types and show the ones that will or at least might work....) file_write_error_message() is documented as handling only UNIX-style errnos, and libwireshark should be usable without libwiretap, so leave it up to its callers to handle Wiretap errors such as WTAP_ERR_SHORT_WRITE. Clean up indentation. svn path=/trunk/; revision=39949
Diffstat (limited to 'alert_box.c')
-rw-r--r--alert_box.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/alert_box.c b/alert_box.c
index fd53c84c9f..666759df0f 100644
--- a/alert_box.c
+++ b/alert_box.c
@@ -80,7 +80,8 @@ read_failure_alert_box(const char *filename, int err)
/*
* Alert box for a failed attempt to write to a file.
- * "err" is assumed to be a UNIX-style errno.
+ * "err" is assumed to be a UNIX-style errno if positive and a
+ * Wiretap error if negative.
*
* XXX - add explanatory secondary text for at least some of the errors;
* various HIGs suggest that you should, for example, suggest that the
@@ -91,8 +92,25 @@ read_failure_alert_box(const char *filename, int err)
void
write_failure_alert_box(const char *filename, int err)
{
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- file_write_error_message(err), filename);
+ if (err < 0) {
+ switch (err) {
+
+ case WTAP_ERR_SHORT_WRITE:
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "A full write couldn't be done to the file \"%s\".",
+ filename);
+ break;
+
+ default:
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "An error occurred while writing to the file \"%s\": %s.",
+ filename, wtap_strerror(err));
+ break;
+ }
+ } else {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ file_write_error_message(err), filename);
+ }
}
/*