The instance [ortus.boxlang.runtime.types.exceptions.ParseException] has no public field or inner class [ERRORCODE]

Description

In the cfcatch object/struct some keys which exist in other engines are missing.

See


Lucee: Extended_Info,Message,Detail,additional,TagContext,ErrorCode,ErrNumber,type,StackTrace,ExtendedInfo

Boxlang:
StackTrace,Detail,ErrNumber,Message,Type,TagContext

Errorcode should be added


Activity

Show:

Brad WoodDecember 30, 2024 at 6:45 PM

The reason the key list in the code above is different is really unrelated to why the errorCode is not accessible. When casting a throwable to a struct, BoxLang ONLY includes the fields that actually apply to that exception type, EVEN THOUGH we also still have the “catch-all” behavior of just returning an empty string any time you ask for a key that doesn’t really exist for a throwable. So, in the case of your code above, the exception being thrown is a KeyNotFoundException which does not have an errorcode. errorCode is specific to custom exceptions, like the kind you create with the cfthrow tag. In fact, if you change that trycf code to throw a custom error like so:

then the errorCode key will come back from the struct key list BIF, as it actually exists.

On a related note, I added some fixes into the dump template for exceptions which wasn’t always showing all the available keys.

The fix for this ticket is that errorCode needed added to the list of special keys which are always “accessible” on any Throwable instance via dereference. If the type of exception doesn’t have that key, we just return a string. Here is the full list of keys you can always dereference on a throwable without error:

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Fix versions

Priority

Sentry

Created December 28, 2024 at 10:45 AM
Updated December 30, 2024 at 6:45 PM
Resolved December 30, 2024 at 6:45 PM