Improve an error message
authorJ. Ali Harlow <ali@juiblex.co.uk>
Thu Jun 09 17:37:09 2016 +0100 (2016-06-09)
changeset 471a3e5e3eaf224
parent 470 7a38fc77fbde
child 472 219c7ea94a42
Improve an error message
librazor/atomic-actions.c
     1.1 --- a/librazor/atomic-actions.c	Wed Jun 08 15:15:27 2016 +0100
     1.2 +++ b/librazor/atomic-actions.c	Thu Jun 09 17:37:09 2016 +0100
     1.3 @@ -365,9 +365,20 @@
     1.4  	free(newbuf);
     1.5  	free(oldbuf);
     1.6  #else
     1.7 +	int code;
     1.8 +	const char *object;
     1.9 +
    1.10  	if (rename(path, dest)) {
    1.11 -		if (!atomic->error)
    1.12 -			atomic->error = razor_error_new_posix(dest);
    1.13 +		if (!atomic->error) {
    1.14 +			code = errno;
    1.15 +			if (access(path, F_OK) < 0)
    1.16 +				object = path;
    1.17 +			else
    1.18 +				object = dest;
    1.19 +			atomic->error = razor_error_new_str(RAZOR_POSIX_ERROR,
    1.20 +							    code, object,
    1.21 +							    strerror(code));
    1.22 +		}
    1.23  		return -1;
    1.24  	}
    1.25  #endif