MicroPython: Fix errors reporting an errno.

pull/1064/head
Phil Howard 2025-03-18 17:50:48 +00:00
rodzic 3d68cf0010
commit 973fade9fd
4 zmienionych plików z 5 dodań i 7 usunięć

Wyświetl plik

@ -21,7 +21,6 @@ static allocator_mode mode = FIXED_HEAP;
static constexpr size_t cpp_heap_size = CPP_FIXED_HEAP_SIZE / 4;
static uint32_t cpp_heap[cpp_heap_size];
static uint32_t ptr = 0;
static char cpp_err_buf[128] = {0};
extern "C" {
#include "cppmem.h"
@ -69,8 +68,7 @@ void* stat_new(std::size_t n) {
}
std::size_t s = alloc_size(n);
if(ptr + s > cpp_heap_size) {
snprintf(cpp_err_buf, sizeof(cpp_err_buf), "Failed to allocate %d bytes.", s * 4);
mp_raise_msg(&mp_type_RuntimeError, cpp_err_buf);
mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("Failed to allocate %d bytes."), s * 4);
return nullptr;
}
alloc_bytes += s * 4;

Wyświetl plik

@ -79,7 +79,7 @@ int32_t jpegdec_seek_callback(JPEGFILE *jpeg, int32_t p) {
int error;
mp_uint_t res = stream_p->ioctl(fhandle, MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &error);
if (res == MP_STREAM_ERROR) {
mp_raise_OSError(MP_ERROR_TEXT(error));
mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("JPEG: seek failed with %d"), error);
}
return seek_s.offset;

Wyświetl plik

@ -136,7 +136,7 @@ size_t fileio_tell(void* fhandle) {
int error;
mp_uint_t res = stream_p->ioctl((mp_obj_t)fhandle, MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &error);
if (res == MP_STREAM_ERROR) {
mp_raise_OSError(MP_ERROR_TEXT(error));
mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("PicoVector: fileio_tell failed with %d"), error);
}
return seek_s.offset;
@ -153,7 +153,7 @@ size_t fileio_seek(void* fhandle, size_t pos) {
int error;
mp_uint_t res = stream_p->ioctl((mp_obj_t)fhandle, MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &error);
if (res == MP_STREAM_ERROR) {
mp_raise_OSError(MP_ERROR_TEXT(error));
mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("PicoVector: fileio_seek failed with %d"), error);
}
return seek_s.offset;

Wyświetl plik

@ -89,7 +89,7 @@ int32_t pngdec_seek_callback(PNGFILE *png, int32_t p) {
int error;
mp_uint_t res = stream_p->ioctl(fhandle, MP_STREAM_SEEK, (mp_uint_t)(uintptr_t)&seek_s, &error);
if (res == MP_STREAM_ERROR) {
mp_raise_OSError(MP_ERROR_TEXT(error));
mp_raise_msg_varg(&mp_type_OSError, MP_ERROR_TEXT("PNG: seek failed with %d"), error);
}
return seek_s.offset;