You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Load.fetch(stringURL:) method invokes try await URLSession.shared.data(from: url) to fetch encoder the first time it is used. If an error occurs (e.g., the method is invoked without networking permissions), it throws an exception.
In the calls to the fetch method, this exception is handled with try?, substituting an empty collection [:] when an error is caught.
In the CoreBPE.bytePairEncode(piece: ranks:) method, there's a force-unwrapping operation return [ranks[piece]!], which causes a fatal error if ranks is an empty collection.
Recommendation: Catching an error from Load.fetch(stringURL:) should fail more decisively, halting execution, instead of progressing with an empty encoder.
The text was updated successfully, but these errors were encountered:
Load.fetch(stringURL:)
method invokestry await URLSession.shared.data(from: url)
to fetch encoder the first time it is used. If an error occurs (e.g., the method is invoked without networking permissions), it throws an exception.In the calls to the
fetch
method, this exception is handled withtry?
, substituting an empty collection[:]
when an error is caught.In the
CoreBPE.bytePairEncode(piece: ranks:)
method, there's a force-unwrapping operationreturn [ranks[piece]!]
, which causes a fatal error ifranks
is an empty collection.Recommendation: Catching an error from
Load.fetch(stringURL:)
should fail more decisively, halting execution, instead of progressing with an empty encoder.The text was updated successfully, but these errors were encountered: