better error handling in the pascal wrapper
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hyung-hwan 2024-02-23 00:54:36 +09:00
parent 14fbbd1f31
commit 1a7d86a293
2 changed files with 6 additions and 6 deletions

View File

@ -155,7 +155,7 @@ func hcl_go_cci_handler(c *C.hcl_t, cmd C.hcl_io_cmd_t, arg unsafe.Pointer) C.in
dst = uintptr(unsafe.Pointer(&ioarg.buf[0])) dst = uintptr(unsafe.Pointer(&ioarg.buf[0]))
for i = 0; i < n; i++ { for i = 0; i < n; i++ {
//ioarg.buf.c[i] = C.hcl_uch_t(buf[i]) //ioarg.buf.c[i] = C.hcl_uch_t(buf[i])
*(*C.hcl_uch_t)(unsafe.Pointer(dst)) = C.hcl_uch_t(buf[i]); *(*C.hcl_uch_t)(unsafe.Pointer(dst)) = C.hcl_uch_t(buf[i])
dst += unsafe.Sizeof(dummy) dst += unsafe.Sizeof(dummy)
} }
} }

View File

@ -347,7 +347,7 @@ label
begin begin
f := SysUtils.FileOpen(filename, SysUtils.fmOpenRead); f := SysUtils.FileOpen(filename, SysUtils.fmOpenRead);
if f = System.THandle(-1) then begin if f = System.THandle(-1) then begin
errmsg := 'failed to open file - ' + filename; errmsg := 'failed to open ' + filename + ' - ' + SysUtils.SysErrorMessage(SysUtils.GetLastOSError());
goto oops; goto oops;
end; end;
@ -367,7 +367,7 @@ begin
while true do begin while true do begin
len := SysUtils.FileRead(f, buf, System.SizeOf(buf)); len := SysUtils.FileRead(f, buf, System.SizeOf(buf));
if len <= -1 then begin if len <= -1 then begin
errmsg := 'failed to read file - ' + filename; errmsg := 'failed to read ' + filename + ' - ' + SysUtils.SysErrorMessage(SysUtils.GetLastOSError());
goto oops; goto oops;
end; end;
if len = 0 then break; if len = 0 then break;
@ -395,7 +395,7 @@ oops:
if feed_ongoing then hcl_endfeed(self.handle); if feed_ongoing then hcl_endfeed(self.handle);
if attached then hcl_detachccio(self.handle); if attached then hcl_detachccio(self.handle);
self.basefile := ''; self.basefile := '';
if f >= -1 then SysUtils.FileClose(f); if f <> System.THandle(-1) then SysUtils.FileClose(f);
raise Exception.Create(errmsg); raise Exception.Create(errmsg);
end; end;