anyone know if there are hard, fixed limits to the...
# cfml-general
w
anyone know if there are hard, fixed limits to the amount of string data you can set for a cfthrow's message or detail value? if it's like most other things in cf, the answer is no, no limit beyond the actual available jvm memory, but i have a situation where i'd like to rethrow a json error payload retrieved from a third party api, and the only way i can do that is to pass the json as one of the thrown exception's attributes (or so i think)
a
I don't know if there is a limit but I've thrown errors with the JSON from an API
✔️ 1
d
Is what you really want to log that json maybe? If so, do you actually need to throw it, rather than look for it somewhere in the request context when certain types of errors are thrown?
d
Maybe there is another way to handle this. When get in the 'catch' portion, create a table in the DB that allows for a primary key, current date/time and a clob field. Write the entire json to the DB before you actually do the 'rethrow'. This would allow you to go to the DB and look at everything (regardless of what CF can do for you). Just a thought !
a
I find it useful to throw it as then it ends up being logged in Sentry which tracks incidents and occurrences etc without any extra work.
In my case it's not a try/catch it's when the API returns an non 200 response - I track the request and the response from the 3rd party API
d
Regardless of the try/catch situation, once you realize that the API has failed (in some way), write to the DB and this will give you a good starting point for review pass errors to see if there is a pattern as why things failed.
a
Yeah, I get that and I'm not shooting it down, just saying that in my API use case Sentry does all that for me as well as alerting that it's happened.
d
Can you post stuff to Sentry without throwing it? (Never used it.)
a
I'm using https://www.forgebox.io/view/sentry so you can just pass in the exception or log a message
sentry is also handling JS errors so it's handy to have it all in one place
w
in my particular case, throwing an exception is the 'correct' way given the nature of what i'm doing, but since i'd be using the json response from another tool outside my control, and therefore no control over the size, i was just confirming there wasn't any realistic limit on the string length
t
I've dumped large json blocks in to
extendedInfo
and that's worked as well, but in my case, that's usually serialized cf objects to get state data when an exception is thrown.
1
b
This is a place where it would be really handy if exceptions in CFML were classes which could be extended
💯 3
In Java, you'd create a class that extended some sort of Exception with additional fields to store data related to the exception.
In CF, the "type" is just a string and the only random place we can stick data is extrainfo and it is required to be a string 😕
But I've totally crammed meaningful JSON into the extrainfo of a CF error before and it seemed to work ok.