set processor's primitive error information before handling #lenient

This commit is contained in:
hyunghwan.chung 2019-10-24 15:17:46 +00:00
parent d73427cbae
commit feb1825c41
5 changed files with 24 additions and 22 deletions

View File

@ -285,16 +285,6 @@ extend Apex
<primitive: #Apex_perform>
self primitiveFailed
}
/* ------------------------------------------------------------------
* COMMON ERROR/EXCEPTION HANDLERS
* ------------------------------------------------------------------ */
method(#dual) error: msgText
{
/* TODO: implement this
Error signal: msgText. */
msgText dump.
}
}
class Object(Apex)

View File

@ -489,6 +489,11 @@ class IndexNotFoundException(NotFoundException)
extend Apex
{
method(#dual) error: text
{
Exception signal: text.
}
method(#dual,#liberal) primitiveFailed(method)
{
| a b msg ec ex |

View File

@ -9,20 +9,27 @@ class(#limited) InputOutputStud(Object) from "io"
class FileAccessor(InputOutputStud) from "io.file"
{
pooldic Flag
{
O_RDONLY := 0,
O_WRONLY := 1
//O_RDONLY from "O_RDONLY",
//O_WRONLY from "O_WRONLY"
}
method(#primitive,#lenient) _open: path flags: flags.
method(#class) on: path for: flags
{
| fa |
fa := self new _open: path flags: flags.
if (fa isError) { self error: "unable to open file" }.
self addToBeFinalized.
if (fa isError) { self error: "Unable to open file %s - %s" strfmt(path, thisProcess primErrorMessage) }.
fa addToBeFinalized.
^fa.
}
method close
{
"CLOSING HANDLLE>..................." dump.
self _close.
self removeToBeFinalized.
}

View File

@ -69,7 +69,7 @@ class System(Apex)
class := self at: class_name. // System at: class_name.
if (class isError)
{
self error: ('Cannot find the class - ' & class_name).
self error: ("Unable to find the class - " & class_name).
}.
self _initialize.

View File

@ -4802,14 +4802,6 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
}
activate_primitive_method_body:
if (MOO_METHOD_GET_PREAMBLE_FLAGS(preamble) & MOO_METHOD_PREAMBLE_FLAG_LENIENT)
{
/* convert soft failure to error return */
moo->sp = stack_base;
MOO_STACK_PUSH (moo, MOO_ERROR_TO_OOP(moo->errnum));
break;
}
/* set the error number in the current process for 'thisProcess primError' */
moo->processor->active->perr = MOO_ERROR_TO_OOP(moo->errnum);
if (moo->errmsg.len > 0)
@ -4832,6 +4824,14 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
moo->processor->active->perrmsg = moo->_nil;
}
if (MOO_METHOD_GET_PREAMBLE_FLAGS(preamble) & MOO_METHOD_PREAMBLE_FLAG_LENIENT)
{
/* convert soft failure to error return */
moo->sp = stack_base;
MOO_STACK_PUSH (moo, moo->processor->active->perr);
break;
}
MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TRAILER(method));
if (MOO_METHOD_GET_CODE_SIZE(method) == 0) /* this trailer size field is not a small integer */
{