Skip to content

Commit 2c4db43

Browse files
committed
Fix printing error messages
This makes `ios-deploy` print error messages for known error codes so that the console log looks like: ``` ios-deploy[13450:4855044] [ !! ] Error 0x1: An unknown error occurred. AFCRemovePath(conn, name) ios-deploy[13450:4855044] [ !! ] Error 0xa: You do not have permission. AFCRemovePath(conn, name) ``` instead of: ``` ios-deploy[13409:4853438] [ !! ] Error 0x1: unknown. AFCRemovePath(conn, name) ios-deploy[13409:4853438] [ !! ] Error 0xa: unknown. AFCRemovePath(conn, name) ``` The fix is to create an error code from the input `error` to match what's defined in `errorcode_to_id` (for some reason, the errors are `OR`'d with `0xe8000000`). This change is taken from the `SDMMobileDevice` project, which is the source for the error codes.
1 parent 0676ee0 commit 2c4db43

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ios-deploy/errors.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,14 @@ const int error_id_to_message_count = sizeof(error_id_to_message) / sizeof(error
511511
const char* get_error_message(unsigned int error) {
512512
const char* id = NULL;
513513

514+
// this creates an error code to match what's defined in `errorcode_to_id`;
515+
// taken from https://github.com/samdmarshall/SDMMobileDevice/blob/c3e1e97b1310c7a7a10f68281752760038b75e16/Framework/include/SDMMobileDevice/SDMMD_Error.h#L512
516+
// note that the `error & 0xff` isn't done here because there are defined errors like `0xe8008001`
517+
const unsigned int error_code = error | 0xe8000000;
518+
514519
// Lookup error localization id
515520
for (int i = 0; i < errorcode_to_id_count; i++) {
516-
if (errorcode_to_id[i].error == error) {
521+
if (errorcode_to_id[i].error == error_code) {
517522
id = errorcode_to_id[i].id;
518523
break;
519524
}

0 commit comments

Comments
 (0)