30 lines
567 B
C#
30 lines
567 B
C#
using BS.Shared.Interface;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AICore.Facade
|
|
{
|
|
public class DefaultErrorExtractor : IApiErrorExtractor
|
|
{
|
|
public IEnumerable<string> ExtractError(string json)
|
|
{
|
|
var result = new List<string>();
|
|
|
|
using (var doc = JsonDocument.Parse(json))
|
|
{
|
|
if (doc.RootElement.TryGetProperty("error", out var error))
|
|
{
|
|
result.Add(error.ToString());
|
|
return result;
|
|
}
|
|
};
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|