Skip to content

Commit

Permalink
publish v0.0.1 and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dancastillo committed Sep 14, 2024
1 parent 60ece2a commit 857869e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works with multi-package repos, or single-package repos to help you version and publish your code. You can find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/light-planets-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@dancastillo/error': patch
---

Initial Release
7 changes: 4 additions & 3 deletions src/create-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ export function createError(code: ErrorCode | string, message: string, details:
/**
* Return error as string
*
* @param {string} formattedErrMessage - The formatted error message
* @returns {string}
*/
function toString(): string {
return `${errName} [${errCode}]: ${errMessage}`
function toString(formattedErrMessage: string): string {
return `${errName} [${errCode}]: ${formattedErrMessage}`
}

/**
Expand Down Expand Up @@ -67,7 +68,7 @@ export function createError(code: ErrorCode | string, message: string, details:
* @returns {string}
*/
toString(): string {
return toString()
return toString(this.message)
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test('Create error :: non error code returns as UnknownError', (t) => {
assert.strictEqual(err.message, 'Not available testing 123')
assert.strictEqual(err.code, 'UNKNOWN')
assert.strictEqual(err.statusCode, 500)
assert.strictEqual(err.toString(), 'UnknownError [UNKNOWN]: Not available')
assert.strictEqual(err.toString(), 'UnknownError [UNKNOWN]: Not available testing 123')
})

test('Missing error required arguements', (t) => {
Expand Down

0 comments on commit 857869e

Please sign in to comment.