
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Common object error library specifically for functional typescript.
Using npm:
npm install obj-err
Or using yarn:
yarn add obj-err
import { errorBuilder, InferError } from 'obj-err';
// Define an error for each specific case
export const NotFounderror = errorBuidler('NotFoundError');
export type NotFounderror = InferError<typeof NotFounderror>;
// Another error with additional properties
export const InputTooShortError = errorBuilder('InputTooShortError', {
id: 'string',
requiredLength: 123,
actualLength: 123,
});
export type InputTooShortError = InferError<typeof InputTooShortError>;
// You can use zod schema for extra properties
import { z } from 'zod';
export const AnotherError = errorBuilder(
'AnotherError',
z.object({
reason: z.string(),
code: z.number(),
})
);
export type AnotherError = InferError<typeof AnotherError>;
export const validateString = (
input: string
): Result<string, InputTooShortError> => {
if (input.length < 5) {
return err(
InputTooShortError('Input is too short', {
cause: new Error('Validation failed'), // Store the original error
extra: {
details: 'The input must be at least 5 characters long.',
requiredLength: 5,
actualLength: input.length,
},
})
);
}
return ok(input);
};
const handleError = (
error: InputTooShortError | NotFounderror | AnotherError
) =>
match(error)
.with(InputTooShortError.is, () => StatusCode.BadRequest)
.with(NotFounderror.is, () => StatusCode.NotFound)
.with(AnotherError.is, () => StatusCode.InternalServerError)
.exhaustive();
Contributions, issues, and feature requests are welcome! Please see CONTRIBUTING.md for details.
To get started with development, fork the repository and run the following commands:
git clone https://github.com/Harineko0/obj-err.git
cd obj-err
npm install
This project is licensed under the MIT License.
FAQs
Common object error library specifically for functional typescript.
We found that obj-err demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.