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
Mutagen's code is written in a lightweight way that means its exceptions are not fully filled out with all the extra information that might be interesting. Often, an exception will just print the very specific field that failed, but not include other important details such as:
4
+
5
+
- FormKey of the record it was from
6
+
- ModKey of the mod it was from
7
+
8
+
It is recommended that you wrap access code in a try/catch that enriches the exception with that extra information.
9
+
10
+
## RecordException Enrichment
11
+
12
+
This enriches an exception relative to a major record's information
The above code will -NOT- include `ModKey`. The ModKey that the record override originated from cannot be inferred automatically and so must be passed in. The above call has a `modKey` parameter that you can pass this information to if you have it.
37
+
38
+
More than likely, though, the best way to do this is to use [ModContexts](../linkcache/ModContexts.md), which contain the information about what Mod the record originated from.
This is an even more specialized version of RecordException that also includes the Subrecord type. Typically this is just used by the Mutagen engine itself, and not applicable to user code.
Copy file name to clipboardExpand all lines: docs/best-practices/FormLinks-Target-Getter-Interfaces.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ if (myTargetNpc.TryResolve(myLinkCache, out var npc))
36
36
// Found a INpc!
37
37
}
38
38
```
39
-
The `TryResolve` call wants to return an `INpc` type to you. But if all it can find is a [readonly `INpcGetter`](../plugins/Binary-Importing.md#read-only-mod-importing), it cannot pretend that it's settable, and so fails to match. This is the result of you asking the system to find an Npc that is settable, when the ones that exist are only getters.
39
+
The `TryResolve` call wants to return an `INpc` type to you. But if all it can find is a [readonly `INpcGetter`](../plugins/Importing-and-Construction.md#read-only-mod-importing), it cannot pretend that it's settable, and so fails to match. This is the result of you asking the system to find an Npc that is settable, when the ones that exist are only getters.
40
40
41
41
You can solve this issue by modifying the TryResolve scope:
0 commit comments