mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
add errors for file decoding
This commit is contained in:
parent
4899ccd5aa
commit
8352d20d73
|
@ -1,6 +1,6 @@
|
||||||
import { styled } from "styled-components";
|
import { styled } from "styled-components";
|
||||||
import { AddressInfo, AgbDebug, useAgbDebug } from "../useAgbDebug.hook";
|
import { AddressInfo, AgbDebug, useAgbDebug } from "../useAgbDebug.hook";
|
||||||
import { useMemo, useState } from "react";
|
import { ReactNode, useMemo, useState } from "react";
|
||||||
|
|
||||||
const BacktraceListWrapper = styled.div`
|
const BacktraceListWrapper = styled.div`
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
|
@ -41,8 +41,15 @@ function DebugBacktraceDecode({
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [backtraceLocationsError, setBacktraceLocationsError] =
|
||||||
|
useState<string>("");
|
||||||
|
|
||||||
if (typeof backtraceAddresses === "string") {
|
if (typeof backtraceAddresses === "string") {
|
||||||
return <DebugError error={backtraceAddresses} />;
|
return (
|
||||||
|
<DebugError>
|
||||||
|
Something went wrong decoding the backtrace: {backtraceAddresses}
|
||||||
|
</DebugError>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -74,23 +81,33 @@ function DebugBacktraceDecode({
|
||||||
if (!files) return;
|
if (!files) return;
|
||||||
const file = files[0];
|
const file = files[0];
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
loadLocations(debug, backtraceAddresses, file).then((data) =>
|
setBacktraceLocationsError("");
|
||||||
setBacktraceLocations(data)
|
loadLocations(debug, backtraceAddresses, file)
|
||||||
);
|
.then((data) => setBacktraceLocations(data))
|
||||||
|
.catch((e) => setBacktraceLocationsError(`${e}`));
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
{backtraceLocationsError && (
|
||||||
|
<DebugError>
|
||||||
|
Something went wrong looking up the addresses in the file provided:{" "}
|
||||||
|
{backtraceLocationsError}
|
||||||
|
</DebugError>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function DebugError({ error }: { error: string }) {
|
const ErrorBlock = styled.div`
|
||||||
return (
|
background-color: #f78f8f;
|
||||||
<>
|
border: 2px solid #9c0a0a;
|
||||||
<p>Something went wrong decoding the backtrace</p>
|
border-radius: 8px;
|
||||||
<p>{error}</p>
|
padding: 20px;
|
||||||
</>
|
margin-top: 10px;
|
||||||
);
|
`;
|
||||||
|
|
||||||
|
function DebugError({ children }: { children: ReactNode }) {
|
||||||
|
return <ErrorBlock>{children}</ErrorBlock>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeNicePath(path: string) {
|
function makeNicePath(path: string) {
|
||||||
|
|
Loading…
Reference in a new issue