`saveRelations` returning `null` I'm using the saveRelations method in the RelationsService to save entry relationships in a plugin I'm working on. Everything is working as expected, however, saveRelations is returning null on success, which seems odd.

Here is a portion of the code I'm working with:

public function addCategoryRelation(CategoryModel $category, EntryModel $entry)
{
    $field        = $craft()-&gt;fields-&gt;getFieldByHandle('handle');
    $handle       = $field-&gt;handle;
    $relations    = $category-&gt;$handle;
    $relationsIds = [];

    /**
     * Get the ids for the relations.
     */
    foreach ($relations as $entry) {
        $relationsIds[] = $entry-&gt;id;
    }

    if (!in_array($entry-&gt;id, array_values($relationsIds))) {
        $relationsIds[] = $entry-&gt;id;
        return craft()-&gt;relations-&gt;saveRelations($field, $category, $relationsIds);
    } else {
        return [
            'error' =&gt; 'Entry already saved.',
        ];
    }
}
You're getting null back simply because the saveRelations() method doesn't actually return anything.

If you need to return true from addCategoryRelation if the relations are successfully saved, or possibly an error message (or false) if they aren't, you can consider wrapping the call to saveRelations() in a try/catch block – something like this should work:

public function addCategoryRelation(CategoryModel $category, EntryModel $entry)
{
    ...
    if (in_array($entry-&gt;id, array_values($relationsIds))) {
        return [
            'error' =&gt; 'Entry already saved.',
        ];
    }
    try {
        $relationsIds[] = $entry-&gt;id;
        return craft()-&gt;relations-&gt;saveRelations($field, $category, $relationsIds);
    } catch (\Exception $e) {
        // Something went wrong – return `false` or an error message, log the exception?
        return false;
    }
    return true;
}