FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
opencode/packages/opencode/src/cli/error.ts at dev · lightsofapollo/opencode · GitHub
lightsofapollo
/
opencode
Public
forked from
anomalyco/opencode
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
opencode
/
packages
/
opencode
/
src
/
cli
/
error.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (52 loc) · 2.22 KB
Breadcrumbs
opencode
/
packages
/
opencode
/
src
/
cli
/
error.ts
Copy path
File metadata and controls
57 lines (52 loc) · 2.22 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import
{
ConfigMarkdown
}
from
"@/config/markdown"
import
{
Config
}
from
"../config/config"
import
{
MCP
}
from
"../mcp"
import
{
Provider
}
from
"../provider/provider"
import
{
UI
}
from
"./ui"
export
function
FormatError
(
input
:
unknown
)
{
if
(
MCP
.
Failed
.
isInstance
(
input
)
)
return
`MCP server "
${
input
.
data
.
name
}
" failed. Note, opencode does not support MCP authentication yet.`
if
(
Provider
.
ModelNotFoundError
.
isInstance
(
input
)
)
{
const
{
providerID
,
modelID
,
suggestions
}
=
input
.
data
return
[
`Model not found:
${
providerID
}
/
${
modelID
}
`
,
...
(
Array
.
isArray
(
suggestions
)
&&
suggestions
.
length
?
[
"Did you mean: "
+
suggestions
.
join
(
", "
)
]
:
[
]
)
,
`Try: \`opencode models\` to list available models`
,
`Or check your config (opencode.json) provider/model names`
,
]
.
join
(
"\n"
)
}
if
(
Provider
.
InitError
.
isInstance
(
input
)
)
{
return
`Failed to initialize provider "
${
input
.
data
.
providerID
}
". Check credentials and configuration.`
}
if
(
Config
.
JsonError
.
isInstance
(
input
)
)
{
return
(
`Config file at
${
input
.
data
.
path
}
is not valid JSON(C)`
+
(
input
.
data
.
message
?
`:
${
input
.
data
.
message
}
`
:
""
)
)
}
if
(
Config
.
ConfigDirectoryTypoError
.
isInstance
(
input
)
)
{
return
`Directory "
${
input
.
data
.
dir
}
" in
${
input
.
data
.
path
}
is not valid. Rename the directory to "
${
input
.
data
.
suggestion
}
" or remove it. This is a common typo.`
}
if
(
ConfigMarkdown
.
FrontmatterError
.
isInstance
(
input
)
)
{
return
input
.
data
.
message
}
if
(
Config
.
InvalidError
.
isInstance
(
input
)
)
return
[
`Configuration is invalid
${
input
.
data
.
path
&&
input
.
data
.
path
!==
"config"
?
` at
${
input
.
data
.
path
}
`
:
""
}
`
+
(
input
.
data
.
message
?
`:
${
input
.
data
.
message
}
`
:
""
)
,
...
(
input
.
data
.
issues
?.
map
(
(
issue
)
=>
"↳ "
+
issue
.
message
+
" "
+
issue
.
path
.
join
(
"."
)
)
??
[
]
)
,
]
.
join
(
"\n"
)
if
(
UI
.
CancelledError
.
isInstance
(
input
)
)
return
""
}
export
function
FormatUnknownError
(
input
:
unknown
)
:
string
{
if
(
input
instanceof
Error
)
{
return
input
.
stack
??
`
${
input
.
name
}
:
${
input
.
message
}
`
}
if
(
typeof
input
===
"object"
&&
input
!==
null
)
{
try
{
return
JSON
.
stringify
(
input
,
null
,
2
)
}
catch
{
return
"Unexpected error (unserializable)"
}
}
return
String
(
input
)
}
Back
|
FazBrowse Home
|
New Git URL