rtmp2: Improve error messages

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1403>
This commit is contained in:
Jan Alexander Steffens (heftig) 2021-12-01 16:23:41 +01:00 committed by GStreamer Marge Bot
parent f2d7b98ea4
commit b22093be3c
3 changed files with 34 additions and 40 deletions

View file

@ -1100,26 +1100,23 @@ send_connect_error (GstRtmp2Sink * self, GError * error)
}
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
GST_DEBUG_OBJECT (self, "Connection was cancelled (%s)",
GST_STR_NULL (error->message));
GST_DEBUG_OBJECT (self, "Connection was cancelled: %s", error->message);
return;
}
GST_ERROR_OBJECT (self, "Failed to connect (%s:%d): %s",
g_quark_to_string (error->domain), error->code,
GST_STR_NULL (error->message));
GST_ERROR_OBJECT (self, "Failed to connect: %s %d %s",
g_quark_to_string (error->domain), error->code, error->message);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED)) {
GST_ELEMENT_ERROR (self, RESOURCE, NOT_AUTHORIZED,
("Not authorized to connect"), ("%s", GST_STR_NULL (error->message)));
("Not authorized to connect: %s", error->message), (NULL));
} else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CONNECTION_REFUSED)) {
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ,
("Could not connect"), ("%s", GST_STR_NULL (error->message)));
("Connection refused: %s", error->message), (NULL));
} else {
GST_ELEMENT_ERROR (self, RESOURCE, FAILED,
("Failed to connect"),
("error %s:%d: %s", g_quark_to_string (error->domain), error->code,
GST_STR_NULL (error->message)));
("Failed to connect: %s", error->message),
("domain %s, code %d", g_quark_to_string (error->domain), error->code));
}
}

View file

@ -954,26 +954,23 @@ send_connect_error (GstRtmp2Src * self, GError * error)
}
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
GST_DEBUG_OBJECT (self, "Connection was cancelled (%s)",
GST_STR_NULL (error->message));
GST_DEBUG_OBJECT (self, "Connection was cancelled: %s", error->message);
return;
}
GST_ERROR_OBJECT (self, "Failed to connect (%s:%d): %s",
g_quark_to_string (error->domain), error->code,
GST_STR_NULL (error->message));
GST_ERROR_OBJECT (self, "Failed to connect: %s %d %s",
g_quark_to_string (error->domain), error->code, error->message);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED)) {
GST_ELEMENT_ERROR (self, RESOURCE, NOT_AUTHORIZED,
("Not authorized to connect"), ("%s", GST_STR_NULL (error->message)));
("Not authorized to connect: %s", error->message), (NULL));
} else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CONNECTION_REFUSED)) {
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ,
("Could not connect"), ("%s", GST_STR_NULL (error->message)));
("Connection refused: %s", error->message), (NULL));
} else {
GST_ELEMENT_ERROR (self, RESOURCE, FAILED,
("Failed to connect"),
("error %s:%d: %s", g_quark_to_string (error->domain), error->code,
GST_STR_NULL (error->message)));
("Failed to connect: %s", error->message),
("domain %s, code %d", g_quark_to_string (error->domain), error->code));
}
}

View file

@ -708,14 +708,14 @@ send_connect_done (const gchar * command_name, GPtrArray * args,
if (!args) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"connect failed: %s", command_name);
"'connect' cmd failed: %s", command_name);
g_object_unref (task);
return;
}
if (args->len < 2) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"connect failed; not enough return arguments");
"'connect' cmd failed; not enough return arguments");
g_object_unref (task);
return;
}
@ -726,7 +726,7 @@ send_connect_done (const gchar * command_name, GPtrArray * args,
code = node ? gst_amf_node_peek_string (node, NULL) : NULL;
if (!code) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"result code missing from connect cmd result");
"'connect' cmd failed; no status code");
g_object_unref (task);
return;
}
@ -750,7 +750,7 @@ send_connect_done (const gchar * command_name, GPtrArray * args,
desc = node ? gst_amf_node_peek_string (node, NULL) : NULL;
if (!desc) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
"Connect rejected; no description");
"'connect' cmd returned '%s'; no description", code);
g_object_unref (task);
return;
}
@ -766,14 +766,14 @@ send_connect_done (const gchar * command_name, GPtrArray * args,
}
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
"unhandled authentication mode: %s", desc);
"'connect' cmd returned unhandled authmod: %s", desc);
g_object_unref (task);
return;
}
if (!g_regex_match (auth_regex, desc, 0, &match_info)) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
"failed to parse auth rejection: %s", desc);
"'connect' cmd returned '%s': %s", code, desc);
g_object_unref (task);
return;
}
@ -833,7 +833,7 @@ send_connect_done (const gchar * command_name, GPtrArray * args,
if (g_str_equal (reason, "authfailed")) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
"authentication failed! wrong credentials?");
"authentication failed; wrong credentials?: %s", desc);
g_object_unref (task);
gst_uri_unref (query);
return;
@ -841,7 +841,7 @@ send_connect_done (const gchar * command_name, GPtrArray * args,
if (!g_str_equal (reason, "needauth")) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
"unhandled rejection reason '%s'", reason);
"authentication failed; reason '%s': %s", reason, desc);
g_object_unref (task);
gst_uri_unref (query);
return;
@ -875,7 +875,7 @@ send_connect_done (const gchar * command_name, GPtrArray * args,
* and password are provided */
g_warn_if_reached ();
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"couldn't generate adobe style authentication query");
"internal error: failed to generate adobe auth query");
g_object_unref (task);
return;
}
@ -885,7 +885,7 @@ send_connect_done (const gchar * command_name, GPtrArray * args,
}
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"unhandled connect result code: %s", code);
"'connect' cmd returned '%s'", code);
g_object_unref (task);
}
@ -1026,7 +1026,7 @@ send_secure_token_response (GTask * task, GstRtmpConnection * connection,
if (!data->location.secure_token || !data->location.secure_token[0]) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
"server requires secure token authentication");
"server requires secureToken but no token provided");
g_object_unref (task);
return;
}
@ -1198,14 +1198,14 @@ create_stream_done (const gchar * command_name, GPtrArray * args,
if (!args) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"createStream failed: %s", command_name);
"'createStream' cmd failed: %s", command_name);
g_object_unref (task);
return;
}
if (args->len < 2) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"createStream failed; not enough return arguments");
"'createStream' cmd failed; not enough return arguments");
g_object_unref (task);
return;
}
@ -1217,7 +1217,7 @@ create_stream_done (const gchar * command_name, GPtrArray * args,
gst_amf_node_dump (result, -1, error_dump);
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"createStream failed: %s", error_dump->str);
"'createStream' cmd failed: %s: %s", command_name, error_dump->str);
g_object_unref (task);
g_string_free (error_dump, TRUE);
@ -1229,7 +1229,7 @@ create_stream_done (const gchar * command_name, GPtrArray * args,
if (data->id == 0) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
"createStream returned ID 0");
"'createStream' cmd returned ID 0");
g_object_unref (task);
return;
}
@ -1291,14 +1291,14 @@ on_publish_or_play_status (const gchar * command_name, GPtrArray * args,
if (!args) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"%s failed: %s", command, command_name);
"'%s' cmd failed: %s", command, command_name);
g_object_unref (task);
return;
}
if (args->len < 2) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"%s failed; not enough return arguments", command);
"'%s' cmd failed; not enough return arguments", command);
g_object_unref (task);
return;
}
@ -1325,7 +1325,7 @@ on_publish_or_play_status (const gchar * command_name, GPtrArray * args,
if (g_strcmp0 (code, "NetStream.Publish.BadName") == 0) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_EXISTS,
"publish denied: stream already exists: %s", info_dump->str);
"publish denied; stream already exists: %s", info_dump->str);
goto out;
}
@ -1345,13 +1345,13 @@ on_publish_or_play_status (const gchar * command_name, GPtrArray * args,
if (g_strcmp0 (code, "NetStream.Play.StreamNotFound") == 0) {
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"play denied: stream not found: %s", info_dump->str);
"play denied; stream not found: %s", info_dump->str);
goto out;
}
}
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED,
"unhandled %s result: %s", command, info_dump->str);
"'%s' cmd failed: %s: %s", command, command_name, info_dump->str);
out:
g_string_free (info_dump, TRUE);