Skip to content

Commit

Permalink
docs(README): GitHubProjectNotFoundError
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Oct 5, 2023
1 parent dbf85ea commit d4291c7
Showing 1 changed file with 38 additions and 9 deletions.
47 changes: 38 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ for (const item of items) {
item.fields.priority,
item.type === "REDACTED"
? "_redacted_"
: item.content.assignees.map(({ login }) => login).join(","),
: item.content.assignees.map(({ login }) => login).join(",")
);
}

Expand Down Expand Up @@ -484,7 +484,7 @@ Resolves with `undefined` if item cannot be found.
```js
const item = await project.items.getByContentRepositoryAndNumber(
repositoryName,
issueOrPullRequestNumber,
issueOrPullRequestNumber
);
```

Expand Down Expand Up @@ -794,7 +794,7 @@ Archives a single item based on the Node ID of its linked issue or pull request.
```js
await project.items.archiveByContentRepositoryAndNumber(
repositoryName,
issueOrPullRequestNumber,
issueOrPullRequestNumber
);
```

Expand Down Expand Up @@ -927,7 +927,7 @@ Removes a single item based on the Node ID of its linked issue or pull request.
```js
await project.items.removeByContentRepositoryAndNumber(
repositoryName,
issueOrPullRequestNumber,
issueOrPullRequestNumber
);
```

Expand Down Expand Up @@ -1000,7 +1000,7 @@ try {
details: error.details,
// log out helpful human-readable error message, but beware that it likely contains user content
},
error.toHumanMessage(),
error.toHumanMessage()
);
} else {
// handle any other error
Expand Down Expand Up @@ -1032,7 +1032,36 @@ try {
code: error.code,
details: error.details,
},
error.toHumanMessage(),
error.toHumanMessage()
);
}

throw error;
}
```

#### `GitHubProjectNotFoundError`

Thrown when a project cannot be found based on the `owner` and `number` passed to the `Project` constructor. The error is also thrown if the project exists but cannot be found based on authentication.

```js
import Project, { GitHubProjectNotFoundError } from "github-project";

try {
await myScript(new Project(options));
} catch (error) {
if (error instanceof GitHubProjectNotFoundError) {
analytics.track("GitHubProjectNotFoundError", {
owner: error.details.owner,
number: error.details.number,
});

myLogger.error(
{
code: error.code,
details: error.details,
},
error.toHumanMessage()
);
}

Expand Down Expand Up @@ -1062,7 +1091,7 @@ try {
<td>
<code>constant</code>
</td>
<td><code>GitHubProjectUnknownFieldError</code></td>
<td><code>GitHubProjectNotFoundError</code></td>
</tr>
<tr>
<th>
Expand Down Expand Up @@ -1156,7 +1185,7 @@ try {
code: error.code,
details: error.details,
},
error.toHumanMessage(),
error.toHumanMessage()
);
}

Expand Down Expand Up @@ -1332,7 +1361,7 @@ try {
code: error.code,
details: error.details,
},
error.toHumanMessage(),
error.toHumanMessage()
);
}

Expand Down

0 comments on commit d4291c7

Please sign in to comment.