@@ -302,23 +302,29 @@ static REBOL_STATE Top_State; // Boot var: holds error state during boot
302
302
** to be bound to the error catalog context.
303
303
** If the message is not found, return null.
304
304
**
305
+ ** NOTE: throws invalid-arg error if id or type are not found
306
+ ** throws invalid-error if id or type are not words
307
+ **
305
308
***********************************************************************/
306
309
{
307
310
REBSER * frame ;
308
311
REBVAL * obj1 ;
309
312
REBVAL * obj2 ;
310
313
311
- if (!IS_WORD (& error -> type ) || !IS_WORD (& error -> id )) return 0 ;
314
+ if (IS_NONE (& error -> type ) || IS_NONE (& error -> id ))
315
+ Trap0 (RE_INVALID_ERROR );
312
316
313
317
// Find the correct error type object in the catalog:
318
+ if (!IS_WORD (& error -> type )) goto invalid_type ;
314
319
frame = VAL_OBJ_FRAME (Get_System (SYS_CATALOG , CAT_ERRORS ));
315
320
obj1 = Find_Word_Value (frame , VAL_WORD_SYM (& error -> type ));
316
- if (!obj1 ) return 0 ;
321
+ if (!obj1 ) goto invalid_type ;
317
322
318
323
// Now find the correct error message for that type:
324
+ if (!IS_WORD (& error -> id )) goto invalid_id ;
319
325
frame = VAL_OBJ_FRAME (obj1 );
320
326
obj2 = Find_Word_Value (frame , VAL_WORD_SYM (& error -> id ));
321
- if (!obj2 ) return 0 ;
327
+ if (!obj2 ) goto invalid_id ;
322
328
323
329
if (num ) {
324
330
obj1 = Find_Word_Value (frame , SYM_CODE );
@@ -329,6 +335,11 @@ static REBOL_STATE Top_State; // Boot var: holds error state during boot
329
335
}
330
336
331
337
return obj2 ;
338
+ invalid_type :
339
+ Trap1 (RE_INVALID_ARG , & error -> type );
340
+ invalid_id :
341
+ Trap1 (RE_INVALID_ARG , & error -> id );
342
+ return 0 ; // just for compiler
332
343
}
333
344
334
345
@@ -371,19 +382,20 @@ static REBOL_STATE Top_State; // Boot var: holds error state during boot
371
382
DISABLE_GC ;
372
383
Do_Bind_Block (err , arg ); // GC-OK (disabled)
373
384
ENABLE_GC ;
374
- if (IS_INTEGER (& error -> code ) && VAL_INT64 (& error -> code )) {
375
- Set_Error_Type (error );
376
- } else {
377
- if (Find_Error_Info (error , & code )) {
378
- SET_INTEGER (& error -> code , code );
379
- }
380
- }
385
+ //It was possible to set error using code, but that's now ignored!
386
+ //@@ https://github.com/Oldes/Rebol-issues/issues/1593
387
+ //if (IS_INTEGER(&error->code) && VAL_INT64(&error->code)) {
388
+ // Set_Error_Type(error);
389
+ //} else {
390
+ if (!Find_Error_Info (error , & code )) code = RE_INVALID_ERROR ;
391
+ SET_INTEGER (& error -> code , code );
392
+
393
+ //}
381
394
// The error code is not valid:
382
- if (IS_NONE (& error -> id )) {
383
- SET_INTEGER (& error -> code , RE_INVALID_ERROR );
395
+ if (VAL_INT64 (& error -> code ) == RE_INVALID_ERROR ) {
384
396
Set_Error_Type (error );
385
397
}
386
- if (VAL_INT64 (& error -> code ) < 100 || VAL_INT64 (& error -> code ) > 1000 )
398
+ if (VAL_INT64 (& error -> code ) < 100 ) // || VAL_INT64(&error->code) > 1000)
387
399
Trap_Arg (arg );
388
400
}
389
401
0 commit comments