Skip to content

Releases: TheEdoRan/next-safe-action

v7.9.0

04 Sep 12:31
c900720
Compare
Choose a tag to compare

7.9.0 (2024-09-04)

Features

  • merge server error handling functions into handleServerError (#257) (c900720)

Description

v7.9.0 merges the functionality of handleServerErrorLog and handleReturnedServerError functions into a single optional initialization function called handleServerError. This change has been made because having two functions for server error handling is unnecessary, you can easily manage both logging and returned error within a single function.

Upgrade guide

Suppose you have this code using next-safe-action < 7.9.0:

import { createSafeActionClient } from "next-safe-action";

const actionClient = createSafeActionClient({
  // handles logging
  handleServerErrorLog(error) {
    console.error("my custom error log:", error.message);
  },
  // handles returned shape
  handleReturnedServerError(error) {
    return {
      message: error.message,
    };
  },
});

With next-safe-action >= 7.9.0 it becomes:

import { createSafeActionClient } from "next-safe-action";

const ac = createSafeActionClient({
  // handles both logging and returned shape
  handleServerError(error) {
    console.error("my custom error log:", error.message);
    return {
      message: error.message,
    };
  },
});

So, minimal refactoring is required, and the action client creation is cleaner this way.


Note

Even if you want to change just the logging mechanism, you still have to return an error shape from handleServerError, otherwise the resulting type would be void.

So, if you want for instance keep the default error message as the returned server error and just update the console logging, you can do it like this:

import { createSafeActionClient, DEFAULT_SERVER_ERROR_MESSAGE } from "next-safe-action";

const ac = createSafeActionClient({
  handleServerError(error) {
    console.error("my custom error log:", error.message);
    return DEFAULT_SERVER_ERROR_MESSAGE;
  },
});

v7.8.2

02 Sep 19:46
8e654bc
Compare
Choose a tag to compare

7.8.2 (2024-09-02)

Documentation

  • update library description (8e654bc)

v7.8.1

29 Aug 22:27
a46b71a
Compare
Choose a tag to compare

7.8.1 (2024-08-29)

Documentation

  • update documentation links (7f9888a)

v7.8.0

29 Aug 13:17
81cd392
Compare
Choose a tag to compare

7.8.0 (2024-08-29)

Features

v7.7.1

20 Aug 21:00
2bf7fa1
Compare
Choose a tag to compare

7.7.1 (2024-08-20)

Bug Fixes

  • types: infer MetadataSchema in SafeActionClient (2bf7fa1)

v7.7.1-beta.1

20 Aug 17:22
52bee97
Compare
Choose a tag to compare
v7.7.1-beta.1 Pre-release
Pre-release

7.7.1-beta.1 (2024-08-20)

Refactors

  • type return of createSafeActionClient (52bee97)

v7.7.0

18 Aug 13:55
d9d326e
Compare
Choose a tag to compare

7.7.0 (2024-08-18)

Features

  • middleware: make createMiddleware function stable (d9d326e)

v7.6.4

17 Aug 22:50
4876d2d
Compare
Choose a tag to compare

7.6.4 (2024-08-17)

Refactors

v7.6.3

16 Aug 17:48
53ddab6
Compare
Choose a tag to compare

7.6.3 (2024-08-16)

Bug Fixes

  • parallelize action callbacks execution (53ddab6)

v7.6.2

14 Aug 17:13
b2c02f0
Compare
Choose a tag to compare

7.6.2 (2024-08-14)

Bug Fixes

  • types: allow omitting input in executeOnMount when it's undefined (b2c02f0), closes #217