No. %Save never throws an exception, just returns a %Status variable. In your scenario it would return an error indicating validation failure on LastName.

Class User.Person Extends %Persistent
{

Property LastName As %String(MAXLEN = 30);

/// do ##class(User.Person).Test()
ClassMethod Test()
{
    set obj = ..%New()
    set obj.LastName = $j("", 50)
    set sc = obj.%Save()    
    w $System.Status.GetErrorText(sc)
}
}

Results in:

ERROR #7201: Datatype value ' ' length longer than MAXLEN allowed of 30
  > ERROR #5802: Datatype validation failed on property 'User.Person:LastName', with value equal to " "

From the docs:

  • <STRINGSTACK> An expression is too long, there are too many expressions in an argument for a single command, or an expression contains many very long strings. Simplify the expression.
  • <MAXSTRING> There has been an attempt to specify or create a data string longer than the implementation allows. The maximum string size is 3,641,144 characters. Attempting to concatenate strings that would result in a string exceeding this maximum string size results in a <MAXSTRING> error.

MAXSTRING is always related to maximum length of 3,641,144 characters for one string (assuming long strings are enabled). STRINGSTACK can be raised in several different circumstances, including a lot of small strings, recursion and so on.

Increasing bbsiz may help avoid STRINGSTACK error, but not MAXSTRING.

In your case use streams by replacing:

set file=object.%Get(i).file

with:

set file=object.%Get(i).%Get("file",,"stream")

Check this answer if you need a CSV file.

If you need some custom format:

// prepare statement
set st =  ##class(%SQL.Statement).%New()
set st.%SelectMode = 1 // ODBC
set sc = st.%Prepare(query)
quit:$$$ISERR(sc) sc

// execute statement
#dim result As %SQL.StatementResult
set result = st.%Execute()
quit:result.%SQLCODE'=0 $$$ERROR($$$SQLError, result.%SQLCODE, result.%Message)

// iterate metadata (for example if you need a header)
#dim metadata As SQL.StatementMetadata
set metadata = result.%GetMetadata()
set columnCount = metadata.columns.Count()

for i=1:1:columnCount {
	#dim column As %SQL.StatementColumn
	set column = metadata.columns.GetAt(i)
}

// iterate results
while result.%Next() {
	for i=1:1:columnCount {
		set value = result.%GetData(i)
	}
}